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

body {
    font-family: system-ui, -apple-system, sans-serif;
    background: #f5f5f5;
    color: #333;
    line-height: 1.5;
}

header {
    background: #2c5f8a;
    padding: 0.75rem 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

header a {
    color: white;
    text-decoration: none;
    font-size: 1.25rem;
    font-weight: 600;
    letter-spacing: 0.01em;
}

.user-menu {
    position: relative;
}

.user-menu-trigger {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: none;
    border: none;
    color: white;
    font-size: 0.9rem;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    border-radius: 5px;
    transition: background 0.15s;
}

.user-menu-trigger:hover {
    background: rgba(255,255,255,0.15);
}

.user-menu-trigger .avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 2px solid rgba(255,255,255,0.5);
}

.user-menu-caret {
    font-size: 0.7rem;
    opacity: 0.7;
    margin-left: 0.1rem;
}

.user-menu-dropdown {
    display: none;
    position: absolute;
    right: 0;
    top: calc(100% + 0.4rem);
    background: white;
    border: 1px solid #ddd;
    border-radius: 7px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.12);
    min-width: 160px;
    z-index: 200;
    overflow: hidden;
    padding: 0.25rem 0;
}

.user-menu.open .user-menu-dropdown {
    display: block;
}

.user-menu-section {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: #aaa;
    padding: 0.5rem 0.875rem 0.2rem;
}

.user-menu-divider {
    height: 1px;
    background: #eee;
    margin: 0.25rem 0;
}

.user-menu-item {
    display: block;
    width: 100%;
    padding: 0.45rem 0.875rem;
    font-size: 0.875rem;
    color: #333;
    text-decoration: none;
    background: none;
    border: none;
    text-align: left;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.1s;
}

.user-menu-item:hover {
    background: #f0f4f8;
    color: #2c5f8a;
}

.user-menu-item-btn {
    width: 100%;
}

.user-menu-item:disabled {
    color: #bbb;
    cursor: default;
}

.user-menu-item:disabled:hover {
    background: none;
    color: #bbb;
}

main {
    max-width: 1100px;
    margin: 1rem auto;
    padding: 0 1rem;
}

h1 {
    font-size: 1.5rem;
    margin-bottom: 1.25rem;
}


/* ── Deck list ── */

.deck-list-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.deck-list-header h1 {
    margin: 0;
}

.deck-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.deck-card {
    display: block;
    background: white;
    border-radius: 8px;
    padding: 1.25rem 1.5rem;
    text-decoration: none;
    color: inherit;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    transition: box-shadow 0.15s;
}

.deck-card:hover {
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.15);
}

.deck-name {
    font-size: 1.1rem;
    font-weight: 600;
}

.deck-langs {
    color: #666;
    font-size: 0.875rem;
    margin-top: 0.2rem;
}


/* ── Quiz ── */

.deck-header {
    margin-bottom: 1.25rem;
}

.deck-header h1 {
    margin-bottom: 0.2rem;
}

.deck-header .subtitle {
    color: #666;
    font-size: 0.9rem;
}

.quiz-card {
    background: white;
    border-radius: 8px;
    padding: 2rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.quiz-expression {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.quiz-example {
    font-style: italic;
    color: #555;
    font-size: 1.05rem;
    margin-bottom: 1.75rem;
}

.quiz-prompt {
    background: #fef3c7;
    color: #92400e;
    padding: 0.625rem 1rem;
    border-radius: 6px;
    font-size: 0.95rem;
    margin-bottom: 1rem;
}

.quiz-form {
    display: flex;
    gap: 0.625rem;
    flex-wrap: wrap;
    align-items: center;
}

.quiz-form input[type="text"] {
    flex: 1;
    min-width: 200px;
    padding: 0.6rem 0.875rem;
    font-size: 1rem;
    border: 2px solid #ddd;
    border-radius: 6px;
    outline: none;
    transition: border-color 0.15s;
}

.quiz-form input[type="text"]:focus {
    border-color: #2c5f8a;
}

.btn {
    display: inline-block;
    padding: 0.6rem 1.25rem;
    font-size: 1rem;
    font-weight: 500;
    line-height: 1.5;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
}

.btn-sm {
    padding: 0.3rem 0.875rem;
    font-size: 0.875rem;
}

.btn-primary {
    background: #2c5f8a;
    color: white;
}

.btn-primary:hover {
    background: #245078;
}

.btn-secondary {
    background: #e5e7eb;
    color: #333;
}

.btn-secondary:hover {
    background: #d1d5db;
}

.btn:disabled {
    opacity: 0.4;
    cursor: default;
    pointer-events: none;
}

.quiz-result {
    margin: 1.5rem 0 0;
    padding: 0.75rem 1rem;
    border-radius: 6px;
    font-size: 1rem;
    font-weight: 500;
}

.quiz-result.correct {
    background: #dcfce7;
    color: #166534;
}

.quiz-result.incorrect {
    background: #fee2e2;
    color: #991b1b;
}

.quiz-result.neutral {
    background: #f3f4f6;
    color: #555;
}

.quiz-answer {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid #eee;
}

.quiz-answer .label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: #999;
    margin-bottom: 0.25rem;
}

.quiz-answer .value {
    font-size: 1.5rem;
    font-weight: 700;
}

.quiz-answer .example {
    font-style: italic;
    color: #555;
    margin-top: 0.5rem;
}

.quiz-answer .notes {
    color: #888;
    font-size: 0.9rem;
    margin-top: 0.625rem;
}

.btn-audio {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.9rem;
    opacity: 0.4;
    padding: 0 0.2rem;
    vertical-align: middle;
    transition: opacity 0.15s;
    flex-shrink: 0;
}

.btn-audio:hover,
.btn-audio.playing {
    opacity: 1;
}

.actions {
    margin-top: 1.75rem;
    display: flex;
    gap: 0.625rem;
    align-items: flex-start;
}

.action-primary {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    margin-right: 0.75rem;
    align-self: flex-start;
}

.kbd-hint {
    font-size: 0.8rem;
    color: #aaa;
    transition: color 0.15s, font-weight 0.15s;
}

.action-primary:hover .kbd-hint {
    color: #555;
    font-weight: 600;
}


/* ── Edit form ── */

.edit-form {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.field-group {
    background: white;
    border-radius: 8px;
    padding: 1rem 1.25rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.field-group h2,
.field-group-heading {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: #999;
    margin-bottom: 0.25rem;
}

.field-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.field-with-button {
    display: flex;
    gap: 0.5rem;
    align-items: stretch;
}

.field-with-button select {
    flex: 1 1 0;
    min-width: 0;
}

#vp-preview {
    min-width: 7rem;
}

.field-row .field {
    flex: 1 1 120px;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.field label {
    font-size: 0.875rem;
    font-weight: 500;
    color: #555;
}

.field input[type="text"],
.field input[type="email"],
.field input[type="number"],
.field select,
.field textarea {
    width: 100%;
    box-sizing: border-box;
    padding: 0.4rem 0.75rem;
    font-size: 1rem;
    line-height: 1.5;
    border: 2px solid #ddd;
    border-radius: 6px;
    outline: none;
    font-family: inherit;
    transition: border-color 0.15s;
}

.field select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23666' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.6rem center;
    padding-right: 2rem;
}

.field input[type="text"]:focus,
.field input[type="email"]:focus,
.field input[type="number"]:focus,
.field select:focus,
.field textarea:focus {
    border-color: #2c5f8a;
}

.field textarea {
    resize: vertical;
}

.expression-input {
    resize: none;
}

.noun-gender-row {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.875rem;
    color: #555;
    cursor: pointer;
    white-space: nowrap;
}

.field-label-row {
    display: flex;
    align-items: center;
    gap: 0.625rem;
}

.card-columns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    column-gap: 1.5rem;
    row-gap: 0.75rem;
    align-items: start;
}

.card-col2   { grid-column: 2; flex-direction: row; align-items: center; gap: 0.625rem; }
.card-col2 select { padding: 0.25rem 0.5rem; flex: 1; }
.card-exam-sl { grid-column: 1; grid-row: 4; }
.card-exam-tl { grid-column: 2; grid-row: 4; }

@media (max-width: 640px) {
    .card-columns {
        grid-template-columns: 1fr;
    }
    .card-col2, .card-exam-sl, .card-exam-tl { grid-column: 1; grid-row: auto; }
}

.btn-suggest {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.625rem;
    font-size: 0.8rem;
    font-weight: 500;
    font-family: inherit;
    line-height: 1.4;
    border: 1.5px solid #c8d8e8;
    border-radius: 4px;
    background: #f0f4f8;
    color: #555;
    cursor: pointer;
    text-decoration: none;
    transition: border-color 0.15s, color 0.15s, background 0.15s;
}

.btn-suggest:hover:not(:disabled) {
    border-color: #2c5f8a;
    color: #2c5f8a;
    background: #dbe9f5;
}

.btn-suggest:disabled {
    opacity: 0.5;
    cursor: default;
}

#suggestions {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
    margin-top: 0.375rem;
}

.suggestion-item {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
    padding: 0.5rem 0.75rem;
    text-align: left;
    background: #f0f4f8;
    border: 1px solid #ddd;
    border-radius: 6px;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.1s, border-color 0.1s;
}

.suggestion-item:hover {
    background: #dbe9f5;
    border-color: #2c5f8a;
}

.suggestion-source {
    font-size: 0.85rem;
    color: #888;
}

.suggestion-target {
    font-size: 0.95rem;
    color: #222;
}

.suggestion-error {
    font-size: 0.875rem;
    color: #991b1b;
    margin-top: 0.25rem;
}

.hidden {
    display: none !important;
}

.audio-player {
    margin-top: 0.375rem;
}

.audio-player audio {
    width: 100%;
    height: 32px;
}

.audio-player.audio-stale audio {
    opacity: 0.4;
}

.audio-clear-warning {
    font-size: 0.8rem;
    color: #92400e;
    margin-top: 0.2rem;
}

.translation-warning {
    font-size: 0.875rem;
    background: #fef3c7;
    color: #92400e;
    border: 1px solid #fcd34d;
    border-radius: 6px;
    padding: 0.5rem 0.75rem;
    margin-top: 0.375rem;
}


/* ── Tags ── */

.tag-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem;
    min-height: 1.5rem;
}

.tag-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
    background: #dbe9f5;
    color: #1e4a6e;
    border-radius: 4px;
    padding: 0.15rem 0.5rem 0.15rem 0.6rem;
    font-size: 0.8rem;
    font-weight: 500;
}

.tag-remove {
    background: none;
    border: none;
    cursor: pointer;
    color: #5580a0;
    font-size: 0.9rem;
    line-height: 1;
    padding: 0 0.1rem;
    opacity: 0.6;
    transition: opacity 0.1s;
}

.tag-remove:hover {
    opacity: 1;
}

.tag-input-row {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
    align-items: center;
}

.tag-input {
    flex: 1;
    min-width: 0;
    padding: 0.4rem 0.75rem;
    font-size: 0.875rem;
    border: 2px solid #ddd;
    border-radius: 6px;
    outline: none;
    font-family: inherit;
    transition: border-color 0.15s;
}

.tag-input:focus {
    border-color: #2c5f8a;
}

.tag-autocomplete {
    position: relative;
    display: flex;
    flex-direction: column;
    background: white;
    border: 1px solid #ddd;
    border-radius: 6px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.1);
    margin-top: 0.25rem;
    overflow: hidden;
}

.tag-ac-item {
    padding: 0.4rem 0.75rem;
    font-size: 0.875rem;
    text-align: left;
    background: none;
    border: none;
    cursor: pointer;
    font-family: inherit;
    color: #333;
    transition: background 0.1s;
}

.tag-ac-item:hover {
    background: #f0f4f8;
}


/* ── Quick-tag (quiz back state) ── */

.quick-tag {
    margin-top: 1.25rem;
    padding-top: 1.25rem;
    border-top: 1px solid #eee;
}


/* ── Study set list ── */

.study-set-list {
    display: flex;
    flex-direction: column;
    gap: 0.625rem;
}

.study-set-item {
    background: white;
    border-radius: 8px;
    padding: 1rem 1.25rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    display: flex;
    align-items: baseline;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.study-set-name {
    font-weight: 600;
    font-size: 1rem;
    color: #333;
}

.study-set-meta {
    color: #888;
    font-size: 0.8rem;
    font-family: monospace;
    flex: 1;
}

.study-set-actions {
    flex-basis: 100%;
    display: flex;
    align-items: center;
    gap: 0.375rem;
    margin-top: 0.25rem;
}

.study-set-actions-right {
    display: flex;
    gap: 0.375rem;
    margin-left: auto;
}

.btn-suggest-danger {
    color: #991b1b;
    border-color: #fca5a5;
}

.btn-suggest-danger:hover:not(:disabled) {
    border-color: #991b1b;
    color: #991b1b;
}

.study-set-empty {
    color: #888;
    font-size: 0.9rem;
    padding: 0.5rem 0;
}


/* ── Study set query help text ── */

.query-help {
    margin-top: 0.5rem;
    font-size: 0.8rem;
    color: #888;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.query-help code {
    background: #f0f4f8;
    border-radius: 3px;
    padding: 0.05em 0.3em;
    font-size: 0.85em;
    color: #1e4a6e;
}


/* ── Words table ── */

.words-toolbar {
    position: sticky;
    top: 0;
    z-index: 20;
    height: 40px;
    background: #f5f5f5;
    display: flex;
    align-items: center;
    gap: 0.625rem;
    border-bottom: 2px solid #e0e0e0;
    margin-bottom: 0;
}

.words-title {
    font-size: 1rem;
    font-weight: 600;
    white-space: nowrap;
}

.words-search {
    flex: 1;
    min-width: 0;
    padding: 0.25rem 0.625rem;
    font-size: 0.875rem;
    border: 2px solid #ddd;
    border-radius: 6px;
    outline: none;
    font-family: inherit;
    transition: border-color 0.15s;
}

.words-search:focus {
    border-color: #2c5f8a;
}

.words-count {
    color: #888;
    font-size: 0.8rem;
    white-space: nowrap;
    min-width: 4rem;
    text-align: right;
}

.words-tag-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
    padding: 0.4rem 0;
    border-bottom: 1px solid #e0e0e0;
}

.tag-filter-chip {
    display: inline-block;
    font-size: 0.72rem;
    padding: 0.1rem 0.4rem;
    background: #dbe9f5;
    color: #1e4a6e;
    border-radius: 3px;
    white-space: nowrap;
    border: 1px solid transparent;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.1s, border-color 0.1s;
}

.tag-filter-chip:hover {
    background: #c5d9eb;
}

.tag-filter-chip.active {
    background: #2c5f8a;
    color: #fff;
    border-color: #1e4a6e;
}

.words-table {
    width: 100%;
    table-layout: fixed;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.words-table thead th {
    position: sticky;
    top: 40px;
    z-index: 10;
    background: white;
    border-bottom: 2px solid #ddd;
    padding: 0.35rem 0.625rem;
    text-align: left;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #777;
    white-space: nowrap;
    overflow: hidden;
}

.words-table thead th.sortable {
    cursor: pointer;
    user-select: none;
}

.words-table thead th.sortable:hover {
    color: #2c5f8a;
}

.words-table thead th.sort-active {
    color: #2c5f8a;
}

.sort-arrow {
    margin-left: 0.3rem;
    margin-right: 0.75rem;
}

.words-table tbody tr:hover td {
    background: #f8f9fa;
}

.words-table tbody td {
    border-bottom: 1px solid #f0f0f0;
}

.words-table td {
    padding: 0.28rem 0.625rem;
    vertical-align: middle;
    overflow: hidden;
}

.cell-flex {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    min-width: 0;
}

.cell-text {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.words-table td:first-child {
    font-weight: 500;
}

.card-examples {
    display: none;
}

.show-examples .card-examples {
    display: table-row;
}

.card-examples td {
    font-style: italic;
    font-size: 0.8rem;
    color: #888;
    padding-top: 0;
    padding-bottom: 0.35rem;
    border-bottom: 1px solid #f0f0f0;
    font-weight: normal !important;
}

.show-examples .card-main td {
    border-bottom: none;
}

.pos-inline {
    color: #aaa;
    font-size: 0.8em;
    font-weight: normal;
}

.words-examples-toggle {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.8rem;
    color: #555;
    cursor: pointer;
    white-space: nowrap;
    user-select: none;
}

.col-resize-handle {
    position: absolute;
    top: 20%;
    right: 0;
    bottom: 20%;
    width: 4px;
    cursor: col-resize;
    z-index: 1;
    border-left: 2px solid #ccc;
    border-right: 2px solid #ccc;
    border-radius: 2px;
    background: transparent;
    transition: border-color 0.15s, background 0.15s;
}

.col-resize-handle:hover,
.col-resize-handle.resizing {
    border-color: #2c5f8a;
    background: rgba(44, 95, 138, 0.15);
}

.deck-tag-palette {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
    margin-bottom: 0.5rem;
}

.tag-pal-chip {
    display: inline-block;
    font-size: 0.72rem;
    padding: 0.1rem 0.4rem;
    background: #fff;
    color: #5580a0;
    border: 1px solid #c5d9eb;
    border-radius: 3px;
    white-space: nowrap;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.1s, color 0.1s;
}

.tag-pal-chip:hover {
    background: #eef4fa;
}

.tag-pal-chip.assigned {
    background: #dbe9f5;
    color: #1e4a6e;
    border-color: #b0cde5;
    font-weight: 500;
}

.tag-pal-chip.assigned:hover {
    background: #c5d9eb;
}

.tag-chip-sm {
    display: inline-block;
    font-size: 0.72rem;
    padding: 0.1rem 0.4rem;
    background: #dbe9f5;
    color: #1e4a6e;
    border-radius: 3px;
    margin-right: 0.2rem;
    white-space: nowrap;
}

.btn-edit-small {
    font-size: 0.8rem;
    color: #2c5f8a;
    text-decoration: none;
    padding: 0.15rem 0.5rem;
    border: 1px solid #c5d9eb;
    border-radius: 4px;
    white-space: nowrap;
    transition: background 0.1s;
}

.btn-edit-small:hover {
    background: #dbe9f5;
}

.decks-actions {
    display: flex;
    gap: 0.625rem;
    margin-bottom: 1.25rem;
}

.familiarity-bar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0.75rem 0 0.25rem;
    font-size: 0.82rem;
}

.familiarity-badge {
    display: inline-block;
    padding: 0.15rem 0.55rem;
    border-radius: 3px;
    font-weight: 600;
    font-size: 0.78rem;
    letter-spacing: 0.02em;
}

.familiarity-badge.familiarity-unlearned { background: #e8e8e8; color: #555; }
.familiarity-badge.familiarity-learning { background: #ffecc0; color: #7a5500; }
.familiarity-badge.familiarity-familiar { background: #d0ecff; color: #1a5a8a; }
.familiarity-badge.familiarity-known    { background: #c8f0d8; color: #1a5a35; }

.familiarity-next {
    color: #666;
}

.score-bar {
    display: flex;
    height: 8px;
    border-radius: 4px;
    overflow: hidden;
    background: #ddd;
    margin: 0.1rem 0 0;
    border: 1px solid #ccc;
    box-sizing: border-box;
    width: 100%;
    flex-basis: 100%;
}

.score-seg { height: 100%; }
.score-seg.score-unlearned { background: #bbb; }
.score-seg.score-learning  { background: #f5c842; }
.score-seg.score-familiar  { background: #6aaddb; }
.score-seg.score-known     { background: #5abf82; }

.btn-override {
    display: inline-block;
    margin-left: 0.75rem;
    padding: 0.15rem 0.55rem;
    font-size: 0.8rem;
    color: #555;
    background: none;
    border: 1px solid #bbb;
    border-radius: 4px;
    cursor: pointer;
    vertical-align: middle;
}

.btn-override:hover {
    background: #f0f0f0;
    border-color: #999;
    color: #333;
}


/* ── Deck sharing ── */

.shared-by-label {
    color: #888;
    font-size: 0.85em;
}

.deck-badge {
    display: inline-block;
    font-size: 0.65rem;
    font-weight: 600;
    padding: 0.1rem 0.45rem;
    border-radius: 3px;
    vertical-align: middle;
    margin-left: 0.4rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.deck-badge-public {
    background: #dbe9f5;
    color: #1e4a6e;
}

.deck-badge-shared {
    background: #e8f5e8;
    color: #1a5c1a;
}

.shared-decks-heading {
    font-size: 1rem;
    font-weight: 600;
    margin: 1.5rem 0 0.75rem;
    color: #555;
}

.sharing-modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.35);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sharing-modal {
    background: white;
    border-radius: 10px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.18);
    max-width: 480px;
    width: calc(100% - 2rem);
    max-height: calc(100vh - 4rem);
    overflow-y: auto;
}

.sharing-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem 0.75rem;
    border-bottom: 1px solid #eee;
}

.sharing-modal-title {
    font-size: 1rem;
    font-weight: 600;
    color: #333;
}

.sharing-modal-close {
    background: none;
    border: none;
    font-size: 1.25rem;
    color: #999;
    cursor: pointer;
    line-height: 1;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
}

.sharing-modal-close:hover {
    color: #333;
    background: #f0f0f0;
}

.sharing-modal-body {
    padding: 1rem 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.share-field-label {
    display: block;
    font-size: 0.75rem;
    font-weight: 600;
    color: #888;
    margin-bottom: 0.35rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.share-public-row {
    display: flex;
    flex-direction: column;
}

.share-visibility-select {
    padding: 0.35rem 0.625rem;
    font-size: 0.875rem;
    border: 2px solid #ddd;
    border-radius: 6px;
    outline: none;
    font-family: inherit;
    background: white;
    cursor: pointer;
    transition: border-color 0.15s;
    max-width: 320px;
}

.share-visibility-select:focus {
    border-color: #2c5f8a;
}

.share-access-select {
    padding: 0.2rem 0.4rem;
    font-size: 0.8rem;
    border: 1.5px solid #c8d8e8;
    border-radius: 4px;
    background: #f0f4f8;
    font-family: inherit;
    cursor: pointer;
    outline: none;
    transition: border-color 0.15s;
}

.share-access-select:focus {
    border-color: #2c5f8a;
}

.share-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
    margin-bottom: 1rem;
}

.share-table th {
    text-align: left;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #aaa;
    padding: 0.25rem 0.5rem;
    border-bottom: 1px solid #eee;
}

.share-table td {
    padding: 0.35rem 0.5rem;
    border-bottom: 1px solid #f5f5f5;
    vertical-align: middle;
}

.share-user-name {
    font-weight: 500;
    margin-right: 0.5rem;
}

.share-user-email {
    color: #888;
    font-size: 0.8rem;
}

.share-users-section,
.share-add-section {
    display: flex;
    flex-direction: column;
}

.share-empty {
    font-size: 0.875rem;
    color: #888;
}

.share-add-form {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    flex-wrap: wrap;
}

.share-email-input {
    padding: 0.35rem 0.75rem;
    font-size: 0.875rem;
    border: 2px solid #ddd;
    border-radius: 6px;
    outline: none;
    font-family: inherit;
    transition: border-color 0.15s;
    width: 220px;
}

.share-email-input:focus {
    border-color: #2c5f8a;
}

/* ── Admin pages ── */

.admin-page {
    max-width: 760px;
}

.admin-error {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fca5a5;
    border-radius: 6px;
    padding: 0.5rem 0.875rem;
    font-size: 0.875rem;
    margin-bottom: 1rem;
}

.admin-card {
    background: white;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    overflow: hidden;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.admin-table th {
    text-align: left;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #999;
    padding: 0.625rem 1rem;
    border-bottom: 1px solid #eee;
    white-space: nowrap;
}

.admin-table td {
    padding: 0.625rem 1rem;
    border-bottom: 1px solid #f3f3f3;
    vertical-align: middle;
}

.admin-table tbody tr:last-child td {
    border-bottom: none;
}

.admin-table tbody tr:hover td {
    background: #fafafa;
}

.admin-cell-email {
    color: #555;
    font-size: 0.825rem;
    width: 38%;
}

.admin-cell-name {
    width: 30%;
}


.admin-cell-actions {
    white-space: nowrap;
    display: flex;
    gap: 0.375rem;
    align-items: center;
}

.role-label {
    font-size: 0.8rem;
}

.role-admin {
    color: #2c5f8a;
    font-weight: 600;
}

.role-user {
    color: #bbb;
}

.btn-edit-danger {
    color: #991b1b;
    border-color: #fca5a5;
}

.btn-edit-danger:hover {
    background: #fee2e2;
    border-color: #991b1b;
}

.admin-you-label {
    font-size: 0.75rem;
    color: #bbb;
    font-style: italic;
}

.admin-add-form {
    border-top: 1px solid #eee;
    padding: 1rem 1rem 1.125rem;
}

.admin-add-heading {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #999;
    margin-bottom: 0.75rem;
}

.admin-add-fields {
    display: flex;
    gap: 0.75rem;
    align-items: flex-end;
    flex-wrap: wrap;
}

.admin-add-field {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.admin-add-field label {
    font-size: 0.8rem;
    font-weight: 500;
    color: #666;
}

.admin-add-field input {
    padding: 0.4rem 0.625rem;
    font-size: 0.875rem;
    border: 2px solid #ddd;
    border-radius: 6px;
    outline: none;
    font-family: inherit;
    transition: border-color 0.15s;
    width: 200px;
}

.admin-add-field input:focus {
    border-color: #2c5f8a;
}

.admin-field-optional {
    font-weight: 400;
    color: #bbb;
    font-size: 0.75rem;
}

.admin-add-submit .btn {
    padding: 0.4rem 1rem;
    font-size: 0.875rem;
}

/* ── Generic modal ── */

.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.35);
    z-index: 100;
}

.modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    border-radius: 10px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.18);
    width: 380px;
    max-width: calc(100vw - 2rem);
    z-index: 101;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem 0.75rem;
    border-bottom: 1px solid #eee;
}

.modal-title {
    font-size: 1rem;
    font-weight: 600;
    color: #333;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1rem;
    color: #aaa;
    cursor: pointer;
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    line-height: 1;
}

.modal-close:hover {
    color: #333;
    background: #f0f0f0;
}

.modal-body {
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.875rem;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    padding: 0.875rem 1.25rem;
    border-top: 1px solid #eee;
}

/* ── Admin backups page ── */

.admin-success {
    background: #dcfce7;
    color: #166534;
    border: 1px solid #86efac;
    border-radius: 6px;
    padding: 0.5rem 0.875rem;
    font-size: 0.875rem;
    margin-bottom: 1rem;
}

.admin-muted {
    color: #888;
    font-size: 0.825rem;
}

.admin-env-header td {
    padding: 0.5rem 1rem 0.25rem;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #aaa;
    background: #fafafa;
    border-bottom: 1px solid #f0f0f0;
}

.admin-env-current {
    background: #dbe9f5;
    color: #1e4a6e;
    font-size: 0.65rem;
    padding: 0.1rem 0.4rem;
    border-radius: 3px;
    margin-left: 0.4rem;
    vertical-align: middle;
}

.admin-restore-warning {
    background: #fef3c7;
    border: 1px solid #fcd34d;
    border-radius: 6px;
    padding: 0.75rem 1rem;
    font-size: 0.875rem;
    color: #92400e;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin: 1rem 0;
}

.share-error {
    width: 100%;
    font-size: 0.875rem;
    color: #991b1b;
    background: #fee2e2;
    border: 1px solid #fca5a5;
    border-radius: 6px;
    padding: 0.4rem 0.75rem;
}
