* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #0a0f14;
    color: #e2e8f0;
    min-height: 100vh;
    padding: 16px 14px 48px;
    background-image:
        radial-gradient(circle at 12% 18%, rgba(16, 185, 129, 0.12) 0%, transparent 30%),
        radial-gradient(circle at 88% 82%, rgba(14, 165, 233, 0.09) 0%, transparent 32%);
}

.top {
    max-width: 760px;
    margin: 0 auto 20px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.brand {
    font-size: 1.28rem;
    font-weight: 700;
    background: linear-gradient(135deg, #34d399 0%, #0ea5e9 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.tagline {
    font-size: 0.82rem;
    color: #94a3b8;
    margin-top: 4px;
    max-width: 420px;
    line-height: 1.35;
}

.header-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    justify-content: flex-end;
}

.btn-header {
    font-size: 0.82rem;
    padding: 8px 12px;
}

.lang-switch {
    display: flex;
    gap: 4px;
    border: 1px solid rgba(52, 211, 153, 0.35);
    border-radius: 10px;
    padding: 2px;
}

.lang-switch button {
    background: transparent;
    border: none;
    color: #94a3b8;
    padding: 6px 10px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.82rem;
    font-family: inherit;
}

.lang-switch button.active {
    background: rgba(16, 185, 129, 0.2);
    color: #5eead4;
}

.steps {
    max-width: 760px;
    margin: 0 auto 18px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.step-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.03);
    font-size: 0.82rem;
    color: #94a3b8;
}

.step-pill .num {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.75rem;
    background: rgba(255, 255, 255, 0.08);
    color: #cbd5e1;
}

.step-pill.active {
    border-color: rgba(52, 211, 153, 0.45);
    color: #e2e8f0;
    background: rgba(16, 185, 129, 0.08);
}

.step-pill.active .num {
    background: rgba(16, 185, 129, 0.35);
    color: #ecfdf5;
}

.card {
    max-width: 760px;
    margin: 0 auto;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(52, 211, 153, 0.22);
    border-radius: 20px;
    padding: 22px 20px 24px;
}

.card h2 {
    font-size: 1.05rem;
    margin-bottom: 10px;
    color: #f1f5f9;
}

.help {
    font-size: 0.88rem;
    color: #94a3b8;
    line-height: 1.45;
    margin-bottom: 16px;
}

.drop {
    border: 2px dashed rgba(52, 211, 153, 0.35);
    border-radius: 16px;
    min-height: 160px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 16px;
    text-align: center;
    color: #cbd5e1;
    background: rgba(0, 0, 0, 0.2);
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
}

.drop:hover, .drop.dragover {
    border-color: rgba(52, 211, 153, 0.65);
    background: rgba(16, 185, 129, 0.06);
}

.drop input[type="file"] { display: none; }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 18px;
    border-radius: 12px;
    border: 1px solid rgba(52, 211, 153, 0.45);
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.35), rgba(14, 165, 233, 0.22));
    color: #ecfdf5;
    font-weight: 600;
    font-size: 0.92rem;
    cursor: pointer;
    font-family: inherit;
}

.btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.btn-ghost {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(52, 211, 153, 0.35);
    color: #5eead4;
    font-weight: 600;
}

.row-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 18px;
    align-items: center;
}

.map-wrap {
    height: 280px;
    border-radius: 14px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.12);
    margin-top: 12px;
}

.search-row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 8px;
    align-items: center;
}

.btn-locate {
    flex: 0 1 auto;
    font-size: 0.82rem;
    padding: 10px 12px;
    white-space: normal;
    text-align: center;
    max-width: 100%;
}

@media (min-width: 520px) {
    .btn-locate {
        white-space: nowrap;
        font-size: 0.88rem;
    }
}

.search-row input {
    flex: 1 1 160px;
    min-width: 100px;
    padding: 12px 14px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    background: rgba(0, 0, 0, 0.25);
    color: #f1f5f9;
    font-size: 0.95rem;
}

.search-row input:focus {
    outline: none;
    border-color: #34d399;
}

.results {
    margin-top: 10px;
    font-size: 0.85rem;
    color: #94a3b8;
    max-height: 120px;
    overflow: auto;
}

.results button.pick {
    display: block;
    width: 100%;
    text-align: left;
    padding: 8px 10px;
    margin-bottom: 6px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(0, 0, 0, 0.2);
    color: #e2e8f0;
    cursor: pointer;
    font-family: inherit;
}

.compass-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    padding: 12px 0;
}

.compass-dial {
    --compass-r: min(104px, 33vw);
    width: min(280px, 82vw);
    height: min(280px, 82vw);
    border-radius: 50%;
    border: 2px solid rgba(52, 211, 153, 0.35);
    position: relative;
    background: radial-gradient(circle at 50% 50%, rgba(16, 185, 129, 0.12), transparent 60%),
        rgba(0, 0, 0, 0.25);
}

.compass-rose {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.compass-sector-label {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 78px;
    margin-left: -39px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1px;
    transform: rotate(var(--a)) translateY(calc(-1 * var(--compass-r))) rotate(calc(-1 * var(--a)));
    font-size: 0.58rem;
    line-height: 1.12;
    color: #94a3b8;
    text-align: center;
    transition: color 0.2s, filter 0.2s, text-shadow 0.2s;
}

.compass-sector-label .cs-dir {
    font-weight: 800;
    font-size: 0.68rem;
    color: #cbd5e1;
    letter-spacing: 0.02em;
}

.compass-sector-label .cs-meta {
    font-size: 0.55rem;
    color: #64748b;
    max-width: 76px;
    hyphens: auto;
}

.compass-sector-label.is-active {
    filter: drop-shadow(0 0 6px rgba(52, 211, 153, 0.65));
}

.compass-sector-label.is-active .cs-dir {
    color: #5eead4;
}

.compass-sector-label.is-active .cs-meta {
    color: #99f6e4;
}

.needle {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 4px;
    height: 42%;
    margin-left: -2px;
    margin-top: -42%;
    background: linear-gradient(#f43f5e, #fb7185);
    border-radius: 2px;
    transform-origin: 50% 100%;
    box-shadow: 0 0 12px rgba(244, 63, 94, 0.45);
}

.needle.needle-locked {
    background: linear-gradient(#fbbf24, #fcd34d);
    box-shadow: 0 0 14px rgba(251, 191, 36, 0.55);
}

.needle-cap {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 14px;
    height: 14px;
    margin: -7px;
    border-radius: 50%;
    background: #1e293b;
    border: 2px solid rgba(52, 211, 153, 0.5);
}

.readout {
    font-size: 1.1rem;
    font-weight: 700;
    color: #5eead4;
}

.compass-room-focus {
    margin: 0;
    max-width: min(320px, 92vw);
    text-align: center;
    font-size: 0.82rem;
    line-height: 1.35;
    color: #a5b4fc;
    font-weight: 600;
}

.compass-room-focus strong {
    color: #c7d2fe;
    font-weight: 700;
}

.compass-room-focus .crf-sec {
    font-size: 0.78rem;
    color: #94a3b8;
    font-weight: 500;
}

.compass-room-focus .crf-lock {
    font-size: 0.74rem;
    color: #64748b;
    font-weight: 500;
    margin-top: 4px;
    display: inline-block;
}

.compass-fix-block {
    margin-top: 18px;
    padding-top: 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.room-select-label {
    display: block;
    font-size: 0.88rem;
    font-weight: 600;
    color: #cbd5e1;
}

.room-select-label span {
    display: block;
    margin-bottom: 6px;
}

.room-select {
    width: 100%;
    max-width: 100%;
    padding: 12px 14px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    background: rgba(0, 0, 0, 0.35);
    color: #e2e8f0;
    font-size: 0.92rem;
    font-family: inherit;
    cursor: pointer;
}

.room-select:focus {
    outline: none;
    border-color: #34d399;
}

.compass-advice {
    padding: 14px 16px;
    border-radius: 14px;
    border: 1px solid rgba(52, 211, 153, 0.28);
    background: rgba(16, 185, 129, 0.08);
    margin-top: 4px;
}

.compass-advice-title {
    font-weight: 700;
    color: #5eead4;
    font-size: 0.92rem;
    margin-bottom: 8px;
    line-height: 1.35;
}

.btn-explain-full {
    margin-top: 12px;
    width: 100%;
    max-width: 100%;
}

.compass-advice-text {
    font-size: 0.86rem;
    color: #cbd5e1;
    line-height: 1.5;
    margin: 0;
}

.slider-row {
    margin-top: 14px;
}

.slider-row label {
    display: block;
    margin-bottom: 6px;
    font-size: 0.88rem;
    color: #cbd5e1;
    font-weight: 600;
}

input[type="range"] {
    width: 100%;
}

.canvas-wrap {
    margin-top: 12px;
    border-radius: 14px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: #020617;
    touch-action: none;
}

canvas#mainCanvas {
    display: block;
    width: 100%;
    height: auto;
}

.hint {
    font-size: 0.82rem;
    color: #64748b;
    margin-top: 8px;
    line-height: 1.4;
}

.status {
    margin-top: 10px;
    font-size: 0.85rem;
    color: #94a3b8;
}

.status.ok { color: #5eead4; }
.status.err { color: #fb7185; }

.compass-status {
    min-height: 1.35em;
    margin-top: 6px;
}

.vastu-details {
    margin-top: 18px;
    padding: 14px 14px 16px;
    border-radius: 14px;
    border: 1px solid rgba(52, 211, 153, 0.2);
    background: rgba(0, 0, 0, 0.22);
}

.vastu-details summary {
    cursor: pointer;
    font-weight: 600;
    color: #cbd5e1;
    list-style: none;
}

.vastu-details summary::-webkit-details-marker { display: none; }

.vastu-details summary::before {
    content: '▸ ';
    color: #34d399;
}

.vastu-details[open] summary::before {
    content: '▾ ';
}

.vastu-guide {
    margin-top: 12px;
    font-size: 0.86rem;
    line-height: 1.5;
    color: #cbd5e1;
}

.vastu-guide p { margin-bottom: 10px; }

.vastu-guide ul {
    margin: 0;
    padding-left: 1.15em;
}

.vastu-guide li { margin-bottom: 10px; }

.vastu-guide strong { color: #5eead4; font-weight: 600; }

.vastu-disclaimer {
    margin-top: 12px;
    font-size: 0.78rem;
    color: #64748b;
    line-height: 1.4;
}

.locate-status {
    font-size: 0.82rem;
    color: #5eead4;
    margin-top: 6px;
    min-height: 1.2em;
}

.compass-advice-deep {
    margin-top: 12px;
    margin-bottom: 14px;
    font-size: 0.84rem;
    line-height: 1.45;
    color: #cbd5e1;
}

.compass-advice-deep .sector-deep h4 {
    font-size: 0.88rem;
    color: #5eead4;
    margin: 12px 0 6px;
    font-weight: 600;
}

.compass-advice-deep .sector-deep h4:first-child {
    margin-top: 0;
}

.compass-advice-deep .sector-deep ul {
    margin: 6px 0 0 1.1em;
    padding: 0;
}

.compass-advice-deep .sector-deep li {
    margin-bottom: 4px;
}

.compass-advice-room-label {
    font-size: 0.82rem;
    font-weight: 600;
    color: #94a3b8;
    margin: 10px 0 6px;
}

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.65);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

#explainOverlay {
    z-index: 1002;
}

#authOverlay {
    z-index: 1003;
}

#guideOverlay {
    z-index: 1004;
}

.modal-guide {
    max-width: min(520px, 96vw);
    max-height: min(88vh, 900px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.guide-body {
    overflow-y: auto;
    flex: 1;
    min-height: 120px;
    max-height: min(58vh, 520px);
    padding-right: 6px;
}

.guide-step {
    margin-bottom: 10px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 10px 12px;
    background: rgba(0, 0, 0, 0.2);
}

.guide-step summary {
    cursor: pointer;
    font-weight: 600;
    color: #f1f5f9;
    font-size: 0.92rem;
}

.guide-step-body {
    margin-top: 10px;
    font-size: 0.86rem;
    line-height: 1.48;
    color: #cbd5e1;
}

.chat-hint-sub {
    font-size: 0.78rem;
    margin-top: 8px;
    color: #94a3b8;
}

.btn-inline-hint {
    padding: 4px 10px;
    font-size: 0.82rem;
    display: inline;
}

.chat-welcome-static {
    white-space: pre-wrap;
    font-size: 0.86rem;
    line-height: 1.48;
}

.header-actions .auth-email {
    max-width: 160px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.78rem;
    color: #94a3b8;
    margin-right: 4px;
}

.modal-explain {
    max-width: min(560px, 96vw);
    max-height: min(90vh, 880px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.explain-sector-line {
    font-size: 0.92rem;
    color: #5eead4;
    margin: 0 0 12px;
    line-height: 1.45;
}

.modal-explain-body {
    overflow-y: auto;
    flex: 1;
    min-height: 100px;
    max-height: min(56vh, 480px);
    padding-right: 6px;
    font-size: 0.88rem;
    line-height: 1.52;
    color: #e2e8f0;
}

.modal-explain-body .sector-deep h4 {
    margin-top: 12px;
}

.explain-room-note {
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    font-size: 0.88rem;
    color: #cbd5e1;
}

.help-sub {
    font-size: 0.86rem;
    color: #94a3b8;
    margin-top: 8px;
    line-height: 1.45;
}

.modal {
    background: #0f172a;
    border: 1px solid rgba(52, 211, 153, 0.3);
    border-radius: 18px;
    padding: 22px;
    max-width: 420px;
    width: 100%;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
}

.modal h3 {
    font-size: 1.1rem;
    margin-bottom: 10px;
    color: #f1f5f9;
}

.modal-hint {
    font-size: 0.82rem;
    color: #94a3b8;
    line-height: 1.45;
    margin-bottom: 14px;
}

.modal-label {
    display: block;
    font-size: 0.88rem;
    color: #cbd5e1;
    margin-bottom: 12px;
}

.modal-label span {
    display: block;
    margin-bottom: 6px;
}

.modal-input {
    width: 100%;
    padding: 12px 14px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    background: rgba(0, 0, 0, 0.35);
    color: #e2e8f0;
    font-family: inherit;
    font-size: 0.9rem;
}

.password-field-wrap {
    position: relative;
    display: block;
}

.password-field-wrap .modal-input-password {
    padding-right: 48px;
    box-sizing: border-box;
}

.btn-password-toggle {
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    padding: 0;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: #94a3b8;
    cursor: pointer;
    transition: color 0.15s, background 0.15s;
}

.btn-password-toggle:hover {
    color: #e2e8f0;
    background: rgba(255, 255, 255, 0.06);
}

.btn-password-toggle:focus-visible {
    outline: 2px solid #34d399;
    outline-offset: 2px;
}

.pwd-icon {
    display: flex;
    align-items: center;
    justify-content: center;
}

.pwd-icon.hidden {
    display: none;
}

.modal-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 14px;
}

.chat-panel {
    position: fixed;
    right: 0;
    top: 0;
    bottom: 0;
    width: min(420px, 100vw);
    z-index: 1001;
    background: #0a0f14;
    border-left: 1px solid rgba(52, 211, 153, 0.25);
    display: flex;
    flex-direction: column;
    box-shadow: -8px 0 32px rgba(0, 0, 0, 0.4);
}

.chat-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    font-weight: 600;
    color: #e2e8f0;
}

.chat-close {
    font-size: 1.5rem;
    line-height: 1;
    padding: 4px 10px;
}

.chat-hint {
    font-size: 0.78rem;
    color: #64748b;
    padding: 10px 16px;
    line-height: 1.4;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 12px 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.chat-bubble {
    padding: 10px 12px;
    border-radius: 12px;
    font-size: 0.86rem;
    line-height: 1.45;
    max-width: 95%;
    white-space: pre-wrap;
    word-break: break-word;
}

.chat-user {
    align-self: flex-end;
    background: rgba(16, 185, 129, 0.22);
    border: 1px solid rgba(52, 211, 153, 0.35);
    color: #ecfdf5;
}

.chat-assistant {
    align-self: flex-start;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #e2e8f0;
}

.chat-typing {
    opacity: 0.7;
    font-style: italic;
}

.chat-input-row {
    padding: 12px 16px 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.chat-input {
    width: 100%;
    padding: 10px 12px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    background: rgba(0, 0, 0, 0.35);
    color: #f1f5f9;
    font-family: inherit;
    font-size: 0.88rem;
    resize: vertical;
    min-height: 52px;
}

.chat-err {
    font-size: 0.8rem;
    color: #fb7185;
    padding: 0 16px 10px;
    min-height: 1.2em;
}

.hidden { display: none !important; }

@media (max-width: 520px) {
    .brand { font-size: 1.1rem; }
    .card { padding: 18px 14px; }
}
