* { box-sizing: border-box; }
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    margin: 0;
    color: #222;
    background: #f7f7f8;
}
.topnav {
    background: #2c3e50;
    padding: 0.6rem 1rem;
}
.topnav a {
    color: #fff;
    text-decoration: none;
    margin-right: 1.2rem;
    font-weight: 500;
}
.topnav a.active { text-decoration: underline; }
main {
    padding: 1rem 1.25rem;
    max-width: 1100px;
    margin: 0 auto;
}
h1 { margin-top: 0.25rem; }
form .row { margin-bottom: 0.85rem; }
label { display: inline-block; min-width: 8rem; font-weight: 500; }
input[type=text], input[type=file], select, textarea {
    padding: 0.35rem 0.5rem;
    border: 1px solid #bbb;
    border-radius: 4px;
    font-size: 1rem;
    min-width: 14rem;
    background: #fff;
}
button {
    padding: 0.4rem 0.9rem;
    border: 1px solid #2c3e50;
    background: #2c3e50;
    color: #fff;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.95rem;
}
button.secondary {
    background: #fff;
    color: #2c3e50;
}
button.danger {
    background: #b03030;
    border-color: #b03030;
}
button[disabled] {
    background: #c8c8c8;
    border-color: #c8c8c8;
    color: #6a6a6a;
    cursor: not-allowed;
}
button.toggle-btn {
    background: #fff;
    color: #2c3e50;
    border: 1px solid #2c3e50;
}
button.toggle-btn.active {
    background: #2c3e50;
    color: #fff;
}
.flash { padding: 0.6rem 0.8rem; border-radius: 4px; margin-bottom: 1rem; }
.flash.ok { background: #d6efd6; color: #1f5e1f; }
.flash.err { background: #f7d6d6; color: #6e1f1f; }
.notes { color: #666; font-size: 0.9rem; }

/* Search page layout */
.list-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-bottom: 0.75rem;
    padding-bottom: 0.6rem;
    border-bottom: 1px solid #e0e0e0;
}
.list-btn {
    background: #fff;
    color: #2c3e50;
    border: 1px solid #2c3e50;
    border-radius: 999px;
    padding: 0.3rem 0.85rem;
    font-size: 0.95rem;
    cursor: pointer;
}
.list-btn:hover { background: #eef3f8; }
.list-btn.active {
    background: #2c3e50;
    color: #fff;
}
.search-controls {
    display: flex;
    gap: 1rem;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 0.6rem;
}
.search-controls > * { flex: 0 0 auto; }
.search-controls .grow { flex: 1 1 auto; min-width: 14rem; }

#results-area {
    max-height: 33vh;
    overflow: auto;
    border: 1px solid #ccc;
    background: #fff;
    border-radius: 4px;
}
#results-area.fullsize {
    /* Used when no Anthropic panel is visible — fill the remaining viewport. */
    max-height: calc(100vh - 240px);
}
table.entries {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--results-font, 1.15rem);
}
table.entries th, table.entries td {
    text-align: left;
    padding: 0.4rem 0.6rem;
    border-bottom: 1px solid #eee;
    vertical-align: top;
    white-space: pre-line;          /* respect real newlines in the value */
    word-break: break-word;
    overflow-wrap: anywhere;
}

/* Font-size toolbar above the results pane */
.results-toolbar {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.4rem;
    margin: 0 0 0.4rem;
}
.results-toolbar .label { color: #666; font-size: 0.85rem; }
.results-toolbar button {
    padding: 0.15rem 0.55rem;
    font-size: 0.9rem;
    line-height: 1.1;
}
table.entries thead th {
    position: sticky;
    top: 0;
    background: #f0f0f3;
}
table.entries tbody tr:hover { background: #fafaff; }

#anthropic-area {
    margin-top: 1.5rem;
    border-top: 2px solid #ddd;
    padding-top: 1rem;
}
#anthropic-area h2 { margin: 0 0 0.6rem; font-size: 1.1rem; }
.anthropic-result {
    background: #fff8e6;
    border: 1px solid #e6c97a;
    padding: 0.7rem 0.9rem;
    border-radius: 4px;
}

.muted { color: #888; }
.empty { padding: 1rem; color: #888; }

/* Manage page editable rows */
.edit-row input { min-width: 8rem; }
.row-actions { white-space: nowrap; }
.row-actions button { margin-right: 0.4rem; }

/* Wrap long values in the wide text cells so the user can see the whole entry. */
table.entries td.cell-english,
table.entries td.cell-chinese {
    word-break: break-word;
    overflow-wrap: anywhere;
    white-space: pre-line;
}

/* List name and the row-action buttons should never break across lines.
   The 1% width is a layout trick: the column shrinks to its content
   width while the remaining space goes to english/chinese. */
table.entries td.cell-list,
table.entries td.row-actions {
    white-space: nowrap;
    word-break: normal;
    overflow-wrap: normal;
    width: 1%;
}

/* Edit-entry modal */
dialog#edit-dialog {
    width: min(720px, 92vw);
    border: 1px solid #2c3e50;
    border-radius: 8px;
    padding: 1.25rem 1.5rem;
    box-shadow: 0 10px 40px rgba(0,0,0,0.25);
}
dialog#edit-dialog::backdrop {
    background: rgba(0,0,0,0.4);
}
dialog#edit-dialog h2 { margin-top: 0; }
dialog#edit-dialog .row { margin-bottom: 0.85rem; }
dialog#edit-dialog label {
    display: block;
    min-width: auto;
    margin-bottom: 0.25rem;
}
dialog#edit-dialog textarea,
dialog#edit-dialog input[type=text] {
    width: 100%;
    font-size: 1rem;
    box-sizing: border-box;
}
dialog#edit-dialog textarea {
    min-height: 5rem;
    resize: vertical;
    font-family: inherit;
    line-height: 1.4;
}
dialog#edit-dialog .dialog-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
