:root {
    --bg: #f6f5f2;
    --surface: #ffffff;
    --border: #ddd8d0;
    --text: #2a2622;
    --text-muted: #6b6355;
    --primary: #4a5a40;
    --primary-dark: #384630;
    --danger: #a13d3d;
    --success: #3d6b4f;
    --error: #a13d3d;
    --flash-success-bg: #e4efe6;
    --flash-error-bg: #f3e2e2;
}

/* --primary-dark is the accent color for hover/links -- lighter than
   --primary here (not darker) so it stays readable against --bg. */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg: #1c1b18;
        --surface: #262420;
        --border: #3c392f;
        --text: #e9e4d8;
        --text-muted: #a89f8c;
        --primary: #8aa876;
        --primary-dark: #b6cca4;
        --danger: #e08787;
        --success: #8fcaa6;
        --error: #e08787;
        --flash-success-bg: #223026;
        --flash-error-bg: #332323;
    }
}

:root[data-theme="dark"] {
    --bg: #1c1b18;
    --surface: #262420;
    --border: #3c392f;
    --text: #e9e4d8;
    --text-muted: #a89f8c;
    --primary: #8aa876;
    --primary-dark: #b6cca4;
    --danger: #e08787;
    --success: #8fcaa6;
    --error: #e08787;
    --flash-success-bg: #223026;
    --flash-error-bg: #332323;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.site-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.theme-toggle {
    background: none;
    border: 1px solid var(--border);
    border-radius: 6px;
    width: 2rem;
    height: 2rem;
    font-size: 1rem;
    line-height: 1;
    cursor: pointer;
    color: var(--text);
}

.theme-toggle:hover {
    border-color: var(--primary);
}

.site-header .brand {
    font-weight: 700;
    font-size: 1.25rem;
    color: var(--primary-dark);
    text-decoration: none;
}

main {
    max-width: 720px;
    margin: 0 auto;
    padding: 1.5rem;
}

.flash-container {
    max-width: 720px;
    margin: 1rem auto 0;
    padding: 0 1.5rem;
}

.flash {
    padding: 0.75rem 1rem;
    border-radius: 6px;
    margin-bottom: 0.5rem;
}

.flash-success {
    background: var(--flash-success-bg);
    color: var(--success);
}

.flash-error {
    background: var(--flash-error-bg);
    color: var(--error);
}

.login-card, .form-card, .error-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 2rem;
    margin-top: 2rem;
}

.login-card {
    max-width: 360px;
    margin: 3rem auto 0;
    text-align: center;
}

.subtitle {
    color: var(--text-muted);
    margin-bottom: 1.5rem;
}

.form-group {
    margin-bottom: 1rem;
    text-align: left;
}

.form-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.25rem;
    font-size: 0.9rem;
}

input[type="text"],
input[type="password"],
textarea {
    width: 100%;
    padding: 0.5rem 0.65rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 1rem;
    font-family: inherit;
}

input:focus, textarea:focus {
    outline: 2px solid var(--primary);
    outline-offset: 1px;
}

.btn-primary {
    display: inline-block;
    background: var(--primary);
    color: white;
    border: none;
    padding: 0.6rem 1.2rem;
    border-radius: 6px;
    font-size: 1rem;
    text-decoration: none;
    cursor: pointer;
}

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-secondary {
    display: inline-block;
    background: none;
    color: var(--text);
    border: 1px solid var(--border);
    padding: 0.5rem 0.9rem;
    border-radius: 6px;
    font-size: 0.9rem;
    white-space: nowrap;
    cursor: pointer;
}

.btn-secondary:hover {
    border-color: var(--primary);
}

.password-field {
    display: flex;
    gap: 0.5rem;
}

.password-field input {
    flex: 1;
    width: auto;
}

.link-button {
    background: none;
    border: none;
    color: var(--primary-dark);
    text-decoration: underline;
    cursor: pointer;
    font-size: inherit;
    padding: 0;
}

.link-button.danger {
    color: var(--danger);
}

.list-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.empty-state {
    color: var(--text-muted);
    text-align: center;
    margin-top: 3rem;
}

.credential-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.credential-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 1.25rem 1.5rem;
    display: flex;
    justify-content: space-between;
    gap: 1rem;
}

.credential-card h2 {
    margin: 0 0 0.5rem;
    font-size: 1.1rem;
}

.credential-card dl {
    margin: 0;
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 0.25rem 0.75rem;
}

.credential-card dt {
    color: var(--text-muted);
    font-size: 0.85rem;
}

.credential-card dd {
    margin: 0;
}

.credential-card dd .link-button {
    margin-left: 0.5rem;
}

.secret-value {
    font-family: ui-monospace, Menlo, Consolas, monospace;
}

.meta {
    color: var(--text-muted);
    font-size: 0.8rem;
    margin: 0.75rem 0 0;
}

.credential-actions {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    align-items: flex-end;
    white-space: nowrap;
}

.form-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-top: 1.5rem;
}
