:root {
    --bg-color: #f8fafc;
    --card-bg: #ffffff;
    --text-primary: #0f172a;
    --text-secondary: #64748b;
    --accent: #2563eb;
    --accent-hover: #1d4ed8;
    --success: #16a34a;
    --danger: #dc2626;
    --border-radius: 12px;
    --transition: all 0.2s ease-in-out;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    padding: 16px;
    display: flex;
    justify-content: center;
}

.container {
    width: 100%;
    max-width: 480px;
}

header {
    margin-bottom: 12px;
    text-align: center;
}

h1 {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-primary);
}

.card {
    background-color: var(--card-bg);
    border-radius: var(--border-radius);
    padding: 20px;
    box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    margin-bottom: 20px;
}

.btn {
    width: 100%;
    padding: 14px;
    font-size: 1rem;
    font-weight: 600;
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: var(--transition);
    text-decoration: none;
    text-align: center;
}

.btn-primary {
    background-color: var(--accent);
    color: white;
}

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

.btn-success {
    background-color: var(--success);
    color: white;
}

.btn-secondary {
    background-color: #e2e8f0;
    color: var(--text-primary);
}

.btn-group {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 24px;
}

.form-group {
    display: flex;
    gap: 8px;
}

input[type="text"],
input[type="password"] {
    flex: 1;
    padding: 12px 16px;
    font-size: 1rem;
    border: 1px solid #cbd5e1;
    border-radius: var(--border-radius);
    outline: none;
    transition: var(--transition);
}

input[type="text"]:focus,
input[type="password"]:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.flash-messages {
    background-color: #eff6ff;
    border-left: 4px solid var(--accent);
    padding: 12px 16px;
    border-radius: 0 var(--border-radius) var(--border-radius) 0;
    margin-bottom: 20px;
    font-size: 0.9rem;
}

h3 {
    font-size: 1.1rem;
    margin-bottom: 12px;
    color: var(--text-secondary);
}

ul {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

li {
    background-color: var(--card-bg);
    padding: 16px;
    border-radius: var(--border-radius);
    box-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

li strong {
    font-size: 1.05rem;
    word-break: break-word;
}

.actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.actions button {
    padding: 8px 12px;
    font-size: 0.85rem;
    font-weight: 500;
    border-radius: 8px;
    border: none;
    cursor: pointer;
}

.btn-check {
    background-color: #e0f2fe;
    color: #0369a1;
}

.btn-delete {
    background-color: #fee2e2;
    color: var(--danger);
}

.helper-text {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 6px;
    text-align: center;
}

@media (min-width: 640px) {
    body {
        padding: 40px;
    }
}

.past-topics-section {
    margin-top: 32px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.topic-name {
    cursor: pointer;
    color: var(--accent);
    text-decoration: underline;
    text-underline-offset: 3px;
}

.topic-name:hover {
    color: var(--accent-hover);
}

.topic-history-list {
    max-height: 55vh;
    overflow-y: auto;
    margin-bottom: 16px;
}

.modal-wide {
    max-width: 440px;
}

.history-item {
    background-color: var(--card-bg);
    padding: 14px 16px;
    border-radius: var(--border-radius);
    box-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1);
    margin-bottom: 10px;
    cursor: pointer;
    transition: var(--transition);
}

.history-item:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1);
}

.history-title {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--accent);
    margin-bottom: 4px;
}

.history-snippet {
    font-size: 0.85rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    justify-content: center;
    align-items: center;
    padding: 16px;
    z-index: 100;
}

.modal-content {
    background-color: var(--card-bg);
    padding: 24px;
    border-radius: var(--border-radius);
    max-width: 400px;
    width: 100%;
    box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1);
}

.modal-header {
    font-weight: 700;
    font-size: 1.1rem;
    margin-bottom: 12px;
}

.modal-body {
    font-size: 0.95rem;
    color: var(--text-primary);
    line-height: 1.5;
    margin-bottom: 20px;
}

.brifli-logo {
    font-family: 'Sansita Swashed', cursive, sans-serif;
    font-weight: 500;
    font-size: 3rem;
    line-height: 1;
    color: #2563eb;
}

.text-link {
    color: var(--accent);
    font-weight: 600;
    text-decoration: none;
}

.text-link:hover {
    color: var(--accent-hover);
    text-decoration: underline;
}

.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid #e2e8f0;
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}