:root {
    --c-deep: #0b2e4f;
    --c-deep2: #0f3a63;
    --c-foam: #e8f4f8;
    --c-wave: #3aa6c9;
    --c-shallow: #7fd4d4;
    --c-sand: #f4e3c8;
    --c-sunset: #f4a261;
    --c-text-dark: #0a1f33;
    --c-text-light: #f4f9fb;
    --shadow: 0 4px 16px rgba(11, 46, 79, 0.18);
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    font-family: 'Noto Sans JP', system-ui, sans-serif;
    background: linear-gradient(180deg, var(--c-deep) 0%, var(--c-deep2) 100%);
    background-attachment: fixed;
    color: var(--c-text-light);
    min-height: 100vh;
}

h1, h2, h3 {
    font-family: 'Comfortaa', 'Noto Sans JP', sans-serif;
    font-weight: 700;
    letter-spacing: 0.02em;
}

a { color: var(--c-shallow); }

.app-shell {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.8rem 1.5rem;
    background: rgba(10, 31, 51, 0.55);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid rgba(127, 212, 212, 0.2);
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-family: 'Comfortaa', sans-serif;
    font-size: 1.2rem;
    font-weight: 700;
}

.wave-icon { font-size: 1.5rem; }

.user-area {
    display: flex;
    align-items: center;
    gap: 1rem;
    font-size: 0.9rem;
}

.user-name { color: var(--c-foam); }

.logout-link {
    color: var(--c-shallow);
    text-decoration: none;
    border: 1px solid var(--c-shallow);
    padding: 0.25rem 0.7rem;
    border-radius: 999px;
    font-size: 0.8rem;
}
.logout-link:hover { background: var(--c-shallow); color: var(--c-deep); }

.app-main {
    flex: 1;
    width: 100%;
    margin: 0 auto;
    padding: 1rem 1.5rem;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.split-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    --split-top: 0.5;
    --split-bottom: 0.5;
}
.split-top {
    flex-grow: var(--split-top);
    flex-shrink: 1;
    flex-basis: 0;
    min-height: 0;
    overflow-y: auto;
    padding-right: 4px;
}
.split-bottom {
    flex-grow: var(--split-bottom);
    flex-shrink: 1;
    flex-basis: 0;
    min-height: 0;
    overflow-y: auto;
    padding-right: 4px;
    display: flex;
    flex-direction: column;
}
.splitter-handle {
    height: 10px;
    margin: 6px 0;
    background: linear-gradient(90deg, transparent, var(--c-wave), transparent);
    opacity: 0.35;
    cursor: row-resize;
    border-radius: 10px;
    transition: opacity 0.15s;
    flex-shrink: 0;
}
.splitter-handle:hover { opacity: 0.75; }
.splitter-handle::before {
    content: '';
    display: block;
    width: 40px;
    height: 3px;
    background: var(--c-foam);
    border-radius: 2px;
    margin: 3px auto;
    opacity: 0.8;
}

.chat-section {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}
.chat-section .chat-log {
    flex: 1;
    height: auto;
    min-height: 0;
}

/* ログインカード */
.login-card {
    margin: 6rem auto;
    max-width: 420px;
    background: rgba(232, 244, 248, 0.07);
    border: 1px solid rgba(127, 212, 212, 0.3);
    border-radius: 16px;
    padding: 2.5rem;
    text-align: center;
    box-shadow: var(--shadow);
}
.login-card h1 { margin-top: 0; color: var(--c-foam); }
.login-card p { color: rgba(244, 249, 251, 0.7); }
.discord-btn {
    display: inline-block;
    margin-top: 1rem;
    background: #5865F2;
    color: #fff;
    padding: 0.7rem 1.4rem;
    border-radius: 999px;
    text-decoration: none;
    font-weight: 700;
}
.discord-btn:hover { background: #4752c4; }

/* タブセクション */
.tabs-section, .chat-section {
    background: rgba(232, 244, 248, 0.06);
    border: 1px solid rgba(127, 212, 212, 0.2);
    border-radius: 14px;
    padding: 1rem 1.2rem;
    box-shadow: var(--shadow);
}

.tabs-bar {
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
    border-bottom: 1px solid rgba(127, 212, 212, 0.2);
    padding-bottom: 0.5rem;
}

.tab {
    background: transparent;
    color: var(--c-foam);
    border: 1px solid transparent;
    padding: 0.5rem 1rem;
    border-radius: 10px 10px 0 0;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.95rem;
    position: relative;
    transition: all 0.2s ease;
}
.tab:hover { background: rgba(127, 212, 212, 0.1); }
.tab.active {
    background: rgba(58, 166, 201, 0.25);
    border-color: var(--c-wave);
    color: #fff;
}
.tab.active::after {
    content: '';
    position: absolute;
    bottom: -0.55rem; left: 10%; right: 10%;
    height: 2px;
    background: var(--c-wave);
    border-radius: 2px;
    box-shadow: 0 0 8px var(--c-wave);
}
.own-badge {
    margin-left: 0.4rem;
    background: var(--c-sunset);
    color: var(--c-deep);
    padding: 1px 6px;
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 700;
}

/* テーブル */
.luggage-table {
    width: 100%;
    border-collapse: collapse;
    color: var(--c-text-light);
}
.luggage-table th {
    text-align: left;
    padding: 0.5rem 0.6rem;
    font-size: 0.85rem;
    color: var(--c-shallow);
    border-bottom: 1px solid rgba(127, 212, 212, 0.25);
    font-weight: 500;
}
.luggage-table td {
    padding: 0.4rem 0.5rem;
    border-bottom: 1px solid rgba(127, 212, 212, 0.1);
}
.luggage-table .check-col { width: 6rem; text-align: center; }
.luggage-table .actions-col { width: 3rem; text-align: center; }

.cat-header {
    cursor: pointer;
    user-select: none;
    background: rgba(58, 166, 201, 0.12);
}
.cat-header:hover { background: rgba(58, 166, 201, 0.2); }
.cat-header td {
    padding: 0.5rem 0.7rem;
    border-bottom: 1px solid rgba(127, 212, 212, 0.25);
    color: var(--c-foam);
    font-weight: 500;
}
.cat-toggle { display: inline-block; width: 1.2rem; color: var(--c-shallow); }
.cat-name { color: var(--c-foam); }
.cat-count {
    margin-left: 0.8rem;
    color: rgba(244, 249, 251, 0.55);
    font-size: 0.8rem;
    font-weight: 400;
}

.luggage-table input[type=text] {
    width: 100%;
    background: transparent;
    border: 1px solid transparent;
    color: var(--c-text-light);
    padding: 0.35rem 0.5rem;
    border-radius: 6px;
    font: inherit;
}
.luggage-table input[type=text]:focus {
    outline: none;
    background: rgba(232, 244, 248, 0.08);
    border-color: var(--c-wave);
}
.luggage-table input[type=text]:disabled { color: rgba(244, 249, 251, 0.55); }

.luggage-table input[type=checkbox] {
    width: 1.2rem;
    height: 1.2rem;
    accent-color: var(--c-wave);
    cursor: pointer;
}

.row-del {
    background: transparent;
    color: var(--c-sunset);
    border: none;
    cursor: pointer;
    font-size: 1.2rem;
}

.add-btn {
    margin-top: 0.8rem;
    background: var(--c-wave);
    color: #fff;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 999px;
    cursor: pointer;
    font: inherit;
}
.add-btn:hover { background: var(--c-shallow); color: var(--c-deep); }

.readonly-note {
    margin-top: 0.8rem;
    color: rgba(244, 249, 251, 0.55);
    font-size: 0.85rem;
}

/* チャット */
.chat-section h2 {
    margin: 0;
    color: var(--c-foam);
    font-size: 1.1rem;
}
.chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.8rem;
}
.chat-header-tools {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}
.model-select {
    background: rgba(10, 31, 51, 0.5);
    color: var(--c-foam);
    border: 1px solid var(--c-shallow);
    border-radius: 999px;
    padding: 0.25rem 0.7rem;
    font: inherit;
    font-size: 0.8rem;
    cursor: pointer;
}
.model-select:focus { outline: none; border-color: var(--c-wave); }
.model-select option { background: var(--c-deep); color: var(--c-foam); }
.reset-btn {
    background: transparent;
    color: var(--c-shallow);
    border: 1px solid var(--c-shallow);
    padding: 0.3rem 0.8rem;
    border-radius: 999px;
    cursor: pointer;
    font: inherit;
    font-size: 0.8rem;
}
.reset-btn:hover { background: var(--c-sunset); color: var(--c-deep); border-color: var(--c-sunset); }

.trip-info-panel {
    padding: 0.5rem 0;
}
.trip-info-hint {
    color: rgba(244, 249, 251, 0.6);
    font-size: 0.8rem;
    margin: 0 0 0.6rem 0;
}
.trip-info-editor {
    width: 100%;
    min-height: 120px;
    background: rgba(10, 31, 51, 0.4);
    border: 1px solid rgba(127, 212, 212, 0.25);
    border-radius: 8px;
    padding: 0.6rem 0.9rem;
    color: var(--c-text-light);
    font: inherit;
    resize: vertical;
    margin: 0.5rem 0;
}
.trip-info-editor:focus {
    outline: none;
    border-color: var(--c-wave);
}
.save-btn {
    background: var(--c-wave);
    color: #fff;
    border: none;
    padding: 0.4rem 1rem;
    border-radius: 999px;
    cursor: pointer;
    font: inherit;
    font-size: 0.85rem;
}
.save-btn:hover { background: var(--c-shallow); color: var(--c-deep); }
.saved-note { margin-left: 0.6rem; color: var(--c-shallow); font-size: 0.8rem; }

.chat-log {
    background: rgba(10, 31, 51, 0.4);
    border-radius: 10px;
    padding: 0.8rem;
    height: 320px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    margin-bottom: 0.8rem;
}

.bubble {
    max-width: 80%;
    padding: 0.6rem 0.9rem;
    border-radius: 12px;
    font-size: 0.92rem;
    line-height: 1.5;
}
.bubble.user {
    align-self: flex-end;
    background: var(--c-wave);
    color: #fff;
    border-bottom-right-radius: 4px;
}
.bubble.assistant {
    align-self: flex-start;
    background: var(--c-sand);
    color: var(--c-deep);
    border-bottom-left-radius: 4px;
}
.bubble-author {
    font-size: 0.7rem;
    opacity: 0.7;
    margin-bottom: 0.2rem;
}
.bubble-text { white-space: pre-wrap; }

.trace-details {
    align-self: stretch;
    font-size: 0.8rem;
    color: rgba(244, 249, 251, 0.7);
}
.trace-details summary {
    cursor: pointer;
    padding: 0.3rem 0.5rem;
    color: var(--c-shallow);
    user-select: none;
}
.trace-details summary:hover { color: var(--c-foam); }
.trace {
    font-family: monospace;
    font-size: 0.75rem;
    color: rgba(244, 249, 251, 0.6);
    background: rgba(0,0,0,0.25);
    padding: 0.5rem 0.7rem;
    border-radius: 6px;
    overflow-x: auto;
    margin-top: 0.3rem;
}
.trace > div { padding: 0.15rem 0; word-break: break-all; }

.chat-input-row {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}
.chat-input-row { align-items: flex-end; }
.chat-input {
    flex: 1;
    background: rgba(232, 244, 248, 0.08);
    border: 1px solid rgba(127, 212, 212, 0.3);
    color: var(--c-text-light);
    padding: 0.6rem 0.9rem;
    border-radius: 18px;
    font: inherit;
    resize: vertical;
    min-height: 2.4rem;
    max-height: 10rem;
    line-height: 1.4;
}
.chat-input:focus {
    outline: none;
    border-color: var(--c-wave);
    background: rgba(232, 244, 248, 0.12);
}
.mic-btn.listening {
    background: var(--c-sunset);
    animation: pulse 1s infinite;
}
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}
.mic-btn, .send-btn {
    background: var(--c-wave);
    color: #fff;
    border: none;
    padding: 0.55rem 0.9rem;
    border-radius: 999px;
    cursor: pointer;
    font: inherit;
}
.mic-btn { padding: 0.55rem 0.7rem; }
.mic-btn:hover, .send-btn:hover { background: var(--c-shallow); color: var(--c-deep); }
.send-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.65);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 500;
    padding: 2rem;
}
.modal-card {
    background: var(--c-deep2);
    border: 1px solid var(--c-shallow);
    border-radius: 14px;
    padding: 1.5rem;
    max-width: 900px;
    width: 100%;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
    box-shadow: var(--shadow);
}
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.modal-header h3 { margin: 0; color: var(--c-foam); }
.modal-hint { color: rgba(244, 249, 251, 0.65); font-size: 0.85rem; margin: 0; }
.export-textarea {
    flex: 1;
    min-height: 400px;
    background: rgba(10, 31, 51, 0.7);
    color: var(--c-foam);
    border: 1px solid rgba(127, 212, 212, 0.25);
    border-radius: 8px;
    padding: 0.8rem;
    font-family: 'Consolas', monospace;
    font-size: 0.8rem;
    resize: vertical;
}

#blazor-error-ui {
    background: var(--c-sunset);
    color: var(--c-deep);
    bottom: 0;
    box-shadow: 0 -1px 8px rgba(0,0,0,0.3);
    display: none;
    left: 0;
    padding: 0.6rem 1.2rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}
#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 0.75rem;
    top: 0.5rem;
}
