/* Buttons */
.btn-primary {
    background: var(--accent);
    color: white;
    border-radius: 8px;
    padding: 0.6rem 1.25rem;
    font-size: 0.875rem;
    font-weight: 500;
    transition: var(--transition);
    display: inline-block;
}
.btn-primary:hover { opacity: 0.9; color: white; }
.btn-primary.saved { background: #00B894; }

.btn-secondary {
    background: var(--bg3);
    color: var(--text2);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.6rem 1.25rem;
    font-size: 0.875rem;
    transition: var(--transition);
}
.btn-secondary:hover { color: var(--text); border-color: var(--border2); }

.btn-danger {
    background: transparent;
    color: #E17055;
    border: 1px solid rgba(225,112,85,0.3);
    border-radius: 8px;
    padding: 0.6rem 1.25rem;
    font-size: 0.875rem;
    transition: var(--transition);
}
.btn-danger:hover { background: rgba(225,112,85,0.1); }

.btn-focus {
    display: inline-block;
    background: var(--accent);
    color: white;
    border-radius: 8px;
    padding: 0.5rem 1rem;
    font-size: 0.825rem;
    font-weight: 500;
    margin-top: 0.5rem;
    transition: var(--transition);
}
.btn-focus:hover { opacity: 0.9; color: white; }

/* Form elements */
.field { display: flex; flex-direction: column; gap: 0.4rem; min-width: 0; }
.field label { font-size: 0.8rem; color: var(--text2); }
.field-row { display: flex; gap: 0.75rem; }
.field-repeat { flex-direction: row; align-items: flex-start; flex-wrap: wrap; gap: 0.6rem; }
.checkbox-label { display: flex; align-items: center; gap: 0.4rem; font-size: 0.8rem; color: var(--text2); cursor: pointer; }
.field-row > .field { flex: 1 1 0; min-width: 0; }
.repeat-options { display: flex; flex-direction: column; gap: 0.6rem; width: 100%; }
.weekday-picker { display: flex; gap: 0.35rem; flex-wrap: wrap; }
.weekday-chip {
    padding: 0.35rem 0.65rem;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--bg3);
    color: var(--text2);
    cursor: pointer;
    font-size: 0.78rem;
    transition: var(--transition);
}
.weekday-chip:hover { border-color: var(--accent); }
.weekday-chip.selected { background: var(--accent); color: #fff; border-color: var(--accent); }

.input {
    background: var(--bg3);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.6rem 0.875rem;
    font-family: var(--font);
    font-size: 0.875rem;
    color: var(--text);
    outline: none;
    transition: var(--transition);
    width: 100%;
    box-sizing: border-box;
    min-width: 0;
}
.input:focus { border-color: var(--accent); }
.input-sm { width: 80px; }

/* iOS Safari sizes date/time inputs from the native widget's intrinsic width as
   long as their native -webkit-appearance is active - author width/min-width/
   max-width (and the earlier -webkit-min-logical-width attempt) are simply not
   honored, so the control still overflowed narrow flex children (e.g. Planner's
   exam-date field). Dropping the native appearance turns them into normal
   boxes that obey the .input width:100%/border-box chain. */
input[type="date"],
input[type="datetime-local"],
input[type="time"],
input[type="month"],
input[type="week"] {
    -webkit-appearance: none;
    appearance: none;
    min-width: 0;
    max-width: 100%;
}

/* With appearance:none iOS centers the value text and collapses the inner shadow
   div to zero height when the input is empty (e.g. unset Setup course goal). */
input::-webkit-date-and-time-value {
    text-align: inherit;
    min-height: 1.2em;
}

.select {
    background: var(--bg3);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.6rem 0.875rem;
    font-family: var(--font);
    font-size: 0.875rem;
    color: var(--text);
    outline: none;
    transition: var(--transition);
    width: 100%;
    cursor: pointer;
}
.select:focus { border-color: var(--accent); }

/* iOS Safari/WKWebView auto-zooms the whole page on focus of any input/select whose computed
   font-size is below 16px, and the viewport meta tag here has no maximum-scale to undo it -
   the page stays zoomed in until the user manually pinches back out. .input/.select's base
   0.875rem (14px) triggers this; bump to 16px on mobile only, so desktop keeps the smaller
   size. Elements that set their own font-size on top of .input (e.g. .note-textarea) need
   their own override - this rule alone won't win that specificity/source-order tie. */
@media (max-width: 768px) {
    .input, .select { font-size: 16px; }
}

/* Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(4px);
}

.modal {
    background: var(--bg2);
    border: 1px solid var(--border2);
    border-radius: 16px;
    width: 440px;
    max-width: 92vw;
    box-sizing: border-box;
    overflow: hidden;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 1rem; font-weight: 500; }
.modal-close { color: var(--text3); font-size: 1rem; width: 28px; height: 28px; border-radius: 6px; display: flex; align-items: center; justify-content: center; background: var(--bg3); }
.modal-close:hover { color: var(--text); }

.modal-body { padding: 1.5rem; display: flex; flex-direction: column; gap: 1rem; }
.modal-footer { padding: 1rem 1.5rem; border-top: 1px solid var(--border); display: flex; gap: 0.5rem; justify-content: flex-end; }

/* Device management (PushDeviceManager, FAB bell) - somewhat wider than the standard .modal
   (440px) so label + "X days ago" + button don't wrap. The list itself scrolls instead of
   letting the modal grow arbitrarily tall when many devices are registered. */
.pdm-modal { width: 520px; }
.pdm-list { display: flex; flex-direction: column; gap: 0.6rem; max-height: 50vh; overflow-y: auto; }
.pdm-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.75rem 0.9rem;
    background: var(--bg3);
    border: 1px solid var(--border);
    border-radius: 10px;
}
.pdm-row-main { display: flex; flex-direction: column; gap: 0.2rem; min-width: 0; }
.pdm-row-label { display: flex; align-items: center; gap: 0.5rem; font-weight: 500; color: var(--text); }
.pdm-row-meta { font-size: 0.8rem; color: var(--text3); }
.pdm-badge {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--accent);
    background: color-mix(in srgb, var(--accent) 15%, transparent);
    border-radius: 999px;
    padding: 0.1rem 0.5rem;
}
/* An additional passkey still awaiting approval (PasskeyDeviceManager) - amber instead of the
   accent color, so a new/unknown entry stands out visually right away instead of looking like a
   normal, already-approved device. */
.pdm-row-pending { border-color: color-mix(in srgb, #E1A93C 40%, var(--border)); }
.pdm-pending-badge {
    font-size: 0.7rem;
    font-weight: 600;
    color: #E1A93C;
    background: color-mix(in srgb, #E1A93C 15%, transparent);
    border-radius: 999px;
    padding: 0.1rem 0.5rem;
}

/* AI chat/agent (AgentChatModal, FAB) - wider than the standard .modal, same reasoning as
   .pdm-modal (message bubbles need more room than a settings list). */
.acm-modal { width: 480px; }
.acm-empty { display: flex; flex-direction: column; gap: 0.75rem; align-items: center; text-align: center; padding: 1rem 0; }

.acm-tabs { display: flex; gap: 0.25rem; border-bottom: 1px solid var(--border); margin: -0.5rem 0 0; }
.acm-tab {
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    padding: 0.5rem 0.9rem;
    font-size: 0.875rem;
    color: var(--text3);
    cursor: pointer;
    transition: var(--transition);
}
.acm-tab:hover { color: var(--text2); }
.acm-tab.active { color: var(--text); border-bottom-color: var(--accent); }

.acm-messages { display: flex; flex-direction: column; gap: 0.6rem; max-height: 45vh; overflow-y: auto; padding-right: 0.15rem; }
.acm-msg { display: flex; }
.acm-msg-user { justify-content: flex-end; }
.acm-msg-assistant { justify-content: flex-start; }
.acm-msg-bubble {
    max-width: 82%;
    padding: 0.6rem 0.9rem;
    border-radius: 12px;
    font-size: 0.875rem;
    line-height: 1.45;
    white-space: pre-wrap;
    overflow-wrap: break-word;
}
.acm-msg-user .acm-msg-bubble { background: var(--accent); color: white; border-bottom-right-radius: 4px; }
.acm-msg-assistant .acm-msg-bubble { background: var(--bg3); color: var(--text); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.acm-sources { font-size: 0.75rem; color: var(--text3); }

.acm-input-row { display: flex; gap: 0.5rem; }
.acm-input-row .input { flex: 1; }

.acm-pending {
    background: color-mix(in srgb, #E1A93C 10%, var(--bg3));
    border: 1px solid color-mix(in srgb, #E1A93C 40%, var(--border));
    border-radius: 10px;
    padding: 0.75rem 0.9rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.acm-pending-title { font-weight: 500; color: var(--text); font-size: 0.875rem; margin: 0; }
.acm-pending-actions { display: flex; gap: 0.5rem; justify-content: flex-end; }

/* Progressive-render skeletons (2026-09, all pages): a placeholder block shown in place of a
   section whose data is still loading, so the page shell paints immediately and nothing ever
   shows a zero/empty value that flips to real data a moment later. Lives in shared.css because
   per-page sheets are deferred (boot-loading.js) and the skeleton must be styled from the very
   first paint. Same look as .dash-card.is-loading in dashboard.css. */
.sl-skeleton {
    position: relative;
    overflow: hidden;
    min-height: 6.5rem;
    border-radius: 12px;
    background: var(--bg2);
}
.sl-skeleton-sm { min-height: 3rem; }
.sl-skeleton-lg { min-height: 14rem; }
.sl-skeleton-xl { min-height: 24rem; }
.sl-skeleton-row { display: flex; flex-direction: column; gap: 0.75rem; }

.sl-skeleton::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent, var(--bg3), transparent);
    animation: sl-skeleton-sweep 1.6s ease-in-out infinite;
}

@keyframes sl-skeleton-sweep {
    from { transform: translateX(-100%); }
    to { transform: translateX(100%); }
}

@media (prefers-reduced-motion: reduce) {
    .sl-skeleton::after { animation: none; opacity: 0.6; }
}

/* Form controls must never be wider than their column. A <select> takes the width of its
   longest <option> - a long course name ("Objektorientierte Programmierung im 1. Semester")
   made the notes editor and the planner's course row wider than a phone screen on iOS. */
.select, .input {
    max-width: 100%;
    min-width: 0;
}
.field, .field-row, .field-row > * {
    min-width: 0;
}
