:root {
  --bg: #f6f7fb; --card: #ffffff; --text: #1c1f2a; --muted: #6b7183; --line: #e4e6ef;
  --accent: #4f46e5; --accent-soft: #eceafd; --danger: #dc2626; --danger-soft: #fdecec;
  --warn: #b45309; --warn-soft: #fef3e2; --ok: #15803d; --ok-soft: #e7f6ec;
  --radius: 14px; --shadow: 0 1px 2px rgba(20,24,40,.06), 0 2px 8px rgba(20,24,40,.04);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1117; --card: #181b24; --text: #e8eaf2; --muted: #9aa0b4; --line: #2a2e3b;
    --accent: #8b85ff; --accent-soft: #24233f; --danger: #f87171; --danger-soft: #3a1d1f;
    --warn: #fbbf24; --warn-soft: #3a2f16; --ok: #4ade80; --ok-soft: #173123;
    --shadow: none; color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }

.app { display: flex; min-height: 100vh; min-height: 100dvh; }
main { flex: 1; min-width: 0; padding: calc(16px + env(safe-area-inset-top)) 16px 96px; max-width: 980px; margin: 0 auto; }

/* Gezinme: masaüstünde yan menü, telefonda alt bar */
.tabs { position: sticky; top: 0; height: 100vh; height: 100dvh; width: calc(210px + env(safe-area-inset-left)); flex-shrink: 0;
  padding: calc(20px + env(safe-area-inset-top)) 12px 20px calc(12px + env(safe-area-inset-left));
  background: var(--card); border-right: 1px solid var(--line); display: flex; flex-direction: column; gap: 4px; }
.brand { font-weight: 700; font-size: 18px; padding: 4px 12px 16px; }
.tabs button { display: flex; align-items: center; gap: 10px; border: 0; background: none; padding: 10px 12px;
  border-radius: 10px; cursor: pointer; text-align: left; color: var(--muted); }
.tabs button:hover { background: var(--bg); }
.tabs button.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.ic { font-size: 18px; }
@media (max-width: 760px) {
  .app { display: block; }
  .tabs { position: fixed; top: auto; bottom: 0; left: 0; right: 0; height: auto; width: auto; z-index: 10;
    flex-direction: row; padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); border-right: 0; border-top: 1px solid var(--line); }
  .brand { display: none; }
  .tabs button { flex: 1; min-width: 0; flex-direction: column; gap: 2px; padding: 6px 0; font-size: 10.5px; text-align: center; }
}
main { padding-right: calc(16px + env(safe-area-inset-right)); }
/* iPad dikey/yatay: yan menü biraz daralır, içerik genişler */
@media (min-width: 761px) and (max-width: 1100px) {
  .tabs { width: calc(180px + env(safe-area-inset-left)); }
  main { padding-left: 20px; padding-right: calc(20px + env(safe-area-inset-right)); }
}
/* Dokunmatik ekranlar (iPhone, iPad): daha büyük dokunma alanları */
@media (pointer: coarse) {
  .btn { min-height: 40px; }
  .btn.sm { min-height: 34px; padding: 6px 12px; }
  .icon-btn { padding: 10px; }
  .chip { padding: 8px 14px; }
  .tabs button { min-height: 44px; }
  input, select, textarea { font-size: 16px; } /* iOS'ta odaklanınca yakınlaştırmayı engeller */
}
@media (hover: none) { .tabs button:hover, .icon-btn:hover { background: none; } .tabs button.active { background: var(--accent-soft); } }

/* Ders notları (dosyalar) */
.file-ic { font-size: 24px; width: 32px; text-align: center; flex-shrink: 0; }
.upload-btn { margin: 0; color: #fff; font-size: 15px; display: inline-flex; align-items: center; }
body.dragging .dropzone { outline: 2px dashed var(--accent); outline-offset: 4px; }
dialog.wide { width: min(920px, calc(100vw - 32px)); }
.preview { display: block; max-width: 100%; max-height: 70vh; margin: 0 auto; border-radius: 10px; }
.preview-frame { width: 100%; height: 70vh; border: 0; border-radius: 10px; background: #fff; }
.text-preview { max-height: 60vh; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; }

h1 { font-size: 24px; margin: 4px 0 2px; }
h2 { font-size: 16px; margin: 0 0 10px; }
.sub { color: var(--muted); margin: 0 0 18px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); margin-bottom: 14px; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 14px; }
.grid2 > .card { margin-bottom: 0; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.empty { color: var(--muted); text-align: center; padding: 18px 8px; }

.btn { border: 1px solid var(--line); background: var(--card); padding: 8px 14px; border-radius: 10px; cursor: pointer; }
.btn:hover { border-color: var(--accent); }
a.btn { text-decoration: none; color: inherit; display: inline-flex; align-items: center; }
.btn.primary { background: var(--accent); color: #fff; border-color: var(--accent); font-weight: 600; }
.btn.danger { color: var(--danger); }
.btn.sm { padding: 4px 10px; font-size: 13px; }
.icon-btn { border: 0; background: none; cursor: pointer; padding: 6px; border-radius: 8px; color: var(--muted); font-size: 15px; }
.icon-btn:hover { background: var(--bg); color: var(--text); }
.row-actions { display: flex; gap: 2px; }

.list { list-style: none; margin: 0; padding: 0; }
.item { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.item:first-child { border-top: 0; }
.item .grow { flex: 1; min-width: 0; }
.item .title { font-weight: 600; overflow-wrap: anywhere; }
.done .title { text-decoration: line-through; color: var(--muted); }
.dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.bar { width: 4px; align-self: stretch; border-radius: 4px; flex-shrink: 0; }
.time { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 13px; min-width: 88px; }

.badge { display: inline-block; font-size: 12px; padding: 2px 8px; border-radius: 99px; background: var(--bg); color: var(--muted); border: 1px solid var(--line); white-space: nowrap; }
.badge.danger { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.badge.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.badge.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.badge.accent { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.now { outline: 2px solid var(--accent); outline-offset: 4px; border-radius: 8px; }

.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.chip { border: 1px solid var(--line); background: var(--card); border-radius: 99px; padding: 5px 12px; cursor: pointer; font-size: 13px; }
.chip.active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* Haftalık program */
.week { display: grid; grid-template-columns: repeat(var(--cols, 5), minmax(0, 1fr)); gap: 10px; }
.day { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; min-height: 120px; }
.day.today { border-color: var(--accent); }
.day h3 { font-size: 13px; margin: 0 0 8px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.slot { border-radius: 10px; padding: 8px; margin-bottom: 8px; cursor: pointer; border-left: 4px solid; background: var(--bg); }
.slot b { display: block; font-size: 13px; overflow-wrap: anywhere; }
.slot span { font-size: 12px; color: var(--muted); display: block; }
@media (max-width: 760px) {
  .week { grid-template-columns: 1fr; }
  .day { min-height: 0; }
  .day.empty-day { display: none; }
}

/* Devamsızlık */
.counter { display: flex; align-items: center; gap: 8px; }
.counter b { min-width: 52px; text-align: center; font-variant-numeric: tabular-nums; }
.progress { height: 6px; background: var(--bg); border-radius: 99px; overflow: hidden; margin-top: 8px; border: 1px solid var(--line); }
.progress > i { display: block; height: 100%; background: var(--ok); }
.progress.warn > i { background: var(--warn); }
.progress.danger > i { background: var(--danger); }

/* Notlar */
.big { font-size: 34px; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }
.exam-row { display: grid; grid-template-columns: 1fr 70px 70px 32px; gap: 6px; margin-bottom: 6px; align-items: center; }
.exam-row input { width: 100%; }
table { width: 100%; border-collapse: collapse; }
td, th { padding: 8px 6px; border-top: 1px solid var(--line); text-align: left; }
th { font-size: 12px; color: var(--muted); font-weight: 600; border-top: 0; }

/* Formlar */
label { display: block; font-size: 13px; color: var(--muted); margin: 10px 0 4px; }
input, select, textarea { width: 100%; padding: 9px 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
input[type=checkbox] { width: 20px; height: 20px; accent-color: var(--accent); flex-shrink: 0; }
input[type=color] { padding: 2px; height: 40px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.form-row > div > label { margin-top: 10px; }
textarea { min-height: 70px; resize: vertical; }
pre { background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 10px; overflow-x: auto; font-size: 12px; white-space: pre; }

dialog { border: 0; border-radius: 18px; padding: 0; width: min(460px, calc(100vw - 32px)); background: var(--card); color: var(--text); box-shadow: 0 20px 60px rgba(0,0,0,.25); }
dialog::backdrop { background: rgba(10,12,20,.45); }
dialog form { padding: 20px; max-height: 85vh; overflow-y: auto; }
dialog h2 { font-size: 18px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; flex-wrap: wrap; }
.modal-actions .left { margin-right: auto; }

.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(84px + env(safe-area-inset-bottom)); background: var(--text); color: var(--bg);
  padding: 10px 16px; border-radius: 10px; z-index: 50; font-size: 14px; max-width: calc(100vw - 32px); }
@media (min-width: 761px) { .toast { bottom: 24px; } }
.sync-pill { font-size: 12px; }
.caps-warning { margin-top: 6px; font-size: 13px; font-weight: 600; color: var(--warn); background: var(--warn-soft); padding: 6px 10px; border-radius: 8px; display: inline-block; }
.caps-warning[hidden] { display: none; }
label.check { display: flex; align-items: center; gap: 8px; color: var(--text); font-size: 14px; margin-top: 12px; cursor: pointer; }
