:root {
  color-scheme: dark;
  --bg: #08131f;
  --surface: #101e2d;
  --surface-2: #17283a;
  --report: #202b35;
  --text: #edf5f7;
  --muted: #9eb0bc;
  --accent: #24b6aa;
  --accent-dark: #0c756d;
  --danger: #ef6a74;
  --border: #304458;
  --focus: #7ce7dc;
  --shadow: 0 18px 48px rgb(0 0 0 / 22%);
  --radius: 1rem;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--bg); }
body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background:
    radial-gradient(circle at 8% -10%, rgb(36 182 170 / 12%), transparent 30rem),
    radial-gradient(circle at 100% 0%, rgb(68 113 156 / 13%), transparent 34rem),
    var(--bg);
  color: var(--text);
  line-height: 1.5;
}
[hidden] { display: none !important; }
button, input, textarea, select { font: inherit; }
button, .button {
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: .7rem;
  padding: .68rem 1rem;
  cursor: pointer;
  background: linear-gradient(135deg, #35c8bc, var(--accent));
  color: #031c1a;
  font-weight: 750;
  line-height: 1.2;
  box-shadow: 0 7px 18px rgb(36 182 170 / 12%);
  transition: border-color 150ms ease, box-shadow 150ms ease, filter 150ms ease, transform 150ms ease;
}
button:hover, .button:hover { filter: brightness(1.08); transform: translateY(-1px); }
button:active, .button:active { transform: translateY(0); }
button:disabled { cursor: not-allowed; opacity: .55; transform: none; }
button.secondary, .button.secondary {
  color: var(--text);
  background: var(--surface-2);
  border-color: var(--border);
  box-shadow: none;
}
button.danger { color: #fff; background: #a92f3b; box-shadow: none; }
button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible, a:focus-visible, summary:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}
a { color: var(--focus); text-underline-offset: .2em; }
.button { display: inline-flex; align-items: center; justify-content: center; width: fit-content; text-decoration: none; }

h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: .25rem; font-size: clamp(1.65rem, 2.4vw, 2.25rem); line-height: 1.12; letter-spacing: -.025em; }
h2 { margin-bottom: .25rem; font-size: clamp(1.1rem, 1.5vw, 1.35rem); line-height: 1.25; }
h3 { margin-bottom: .25rem; font-size: 1rem; }

label { display: grid; align-content: start; gap: .45rem; color: #c5d3dc; font-size: .9rem; font-weight: 650; }
input, textarea, select {
  width: 100%;
  min-height: 44px;
  color: var(--text);
  background: rgb(5 15 25 / 72%);
  border: 1px solid #385069;
  border-radius: .7rem;
  padding: .72rem .82rem;
  font-weight: 450;
  line-height: 1.4;
  transition: border-color 150ms ease, box-shadow 150ms ease, background 150ms ease;
}
textarea { min-height: 92px; resize: vertical; }
input:hover, textarea:hover, select:hover { border-color: #52718f; }
input:focus, textarea:focus, select:focus {
  border-color: var(--accent);
  background: #091522;
  box-shadow: 0 0 0 3px rgb(36 182 170 / 12%);
}
input:disabled, textarea:disabled, select:disabled { color: #8395a2; background: #111c28; cursor: not-allowed; }
input[type="checkbox"], input[type="radio"] { min-height: auto; accent-color: var(--accent); }

.shell { min-height: 100vh; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 15;
  border-bottom: 1px solid rgb(69 94 119 / 70%);
  background: rgb(8 19 31 / 88%);
  box-shadow: 0 10px 30px rgb(0 0 0 / 18%);
  backdrop-filter: blur(18px);
}
.topbar-inner {
  width: min(1480px, calc(100% - 2rem));
  min-height: 70px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: clamp(.8rem, 2vw, 1.5rem);
}
.brand-area { display: grid; min-width: max-content; line-height: 1.15; }
.brand { color: var(--text); text-decoration: none; font-size: 1.22rem; font-weight: 850; letter-spacing: -.02em; }
.brand::before { content: ''; display: inline-block; width: .7rem; height: .7rem; margin-right: .55rem; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 5px rgb(36 182 170 / 13%); }
.brand-subtitle { margin: .22rem 0 0 1.3rem; color: var(--muted); font-size: .7rem; letter-spacing: .04em; }
.navigation {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .2rem;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: thin;
}
.navigation a {
  flex: 0 0 auto;
  position: relative;
  padding: .62rem .72rem;
  border-radius: .6rem;
  color: var(--muted);
  font-size: .88rem;
  font-weight: 650;
  text-decoration: none;
  white-space: nowrap;
}
.navigation a:hover { color: var(--text); background: rgb(255 255 255 / 5%); }
.navigation a[aria-current="page"] { color: #d8fffa; background: rgb(36 182 170 / 13%); }
.navigation a[aria-current="page"]::after {
  content: '';
  position: absolute;
  right: .7rem;
  bottom: .24rem;
  left: .7rem;
  height: 2px;
  border-radius: 2px;
  background: var(--accent);
}
.account-menu { display: flex; align-items: center; justify-content: flex-end; gap: .55rem; min-width: max-content; }
.user-chip { max-width: 11rem; overflow: hidden; padding: .42rem .68rem; border: 1px solid var(--border); border-radius: 999px; color: #c5d3dc; background: rgb(23 40 58 / 62%); font-size: .8rem; text-overflow: ellipsis; white-space: nowrap; }
.logout-button { min-height: 36px; padding: .5rem .7rem; font-size: .82rem; }
.app-content { min-width: 0; }

.page { width: min(1240px, calc(100% - 2.5rem)); margin: clamp(1.25rem, 3vw, 2.5rem) auto; }
.page--wide { width: min(1480px, calc(100% - 2.5rem)); }
.narrow { width: min(520px, calc(100% - 2rem)); margin-top: clamp(2rem, 9vh, 6rem); }
.page-header { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; padding: .2rem .1rem .45rem; }
.page-header > h1 { margin: 0; }
.card {
  min-width: 0;
  background: linear-gradient(145deg, rgb(18 34 50 / 96%), rgb(13 27 42 / 96%));
  border: 1px solid rgb(62 85 108 / 85%);
  border-radius: var(--radius);
  padding: clamp(1rem, 2vw, 1.4rem);
  box-shadow: var(--shadow);
}
.card > h2:first-child, .card > .cluster:first-child > h2:first-child { margin-bottom: .25rem; }
.stack { display: grid; gap: 1rem; }
.cluster { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; }
.muted { color: var(--muted); }
.error { color: #ff9ba3; }
.success { color: #7ce7c2; }
.field-hint { color: var(--muted); font-size: .76rem; font-weight: 450; line-height: 1.35; }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 210px), 1fr)); gap: 1rem; }
.metric-card { position: relative; display: grid; gap: .28rem; overflow: hidden; }
.metric-card::after { content: ''; position: absolute; right: -1.8rem; bottom: -2.5rem; width: 7rem; height: 7rem; border-radius: 50%; background: rgb(36 182 170 / 7%); }
.metric-card strong { color: var(--focus); font-size: clamp(1.7rem, 3vw, 2.15rem); font-variant-numeric: tabular-nums; }
.metric-card span { color: #c5d3dc; }
.study-flow { width: 100%; min-height: 220px; color: var(--muted); }
.study-flow .flow-node { fill: var(--surface-2); stroke: var(--accent); stroke-width: 3; }
.study-flow .primary-endpoint { fill: var(--accent-dark); stroke: var(--focus); stroke-width: 4; }
.study-flow text { fill: var(--text); font-size: 15px; font-weight: 700; }
.session-card { display: grid; gap: .8rem; }
.badge { display: inline-flex; align-items: center; width: fit-content; min-height: 1.75rem; padding: .25rem .65rem; border: 1px solid rgb(61 143 151 / 45%); border-radius: 999px; background: #173749; color: #a4e7e2; font-size: .78rem; font-weight: 700; }

.table-wrap { width: 100%; overflow-x: auto; border: 1px solid rgb(48 68 88 / 70%); border-radius: .75rem; }
table { width: 100%; min-width: 720px; border-collapse: separate; border-spacing: 0; }
th, td { padding: .78rem .82rem; text-align: left; border-bottom: 1px solid rgb(48 68 88 / 72%); vertical-align: middle; }
th { position: sticky; top: 0; z-index: 1; color: #c7d8e2; background: #132438; font-size: .78rem; letter-spacing: .025em; text-transform: uppercase; }
tbody tr:nth-child(even) { background: rgb(255 255 255 / 1.5%); }
tbody tr:hover { background: rgb(36 182 170 / 5%); }
tbody tr:last-child td { border-bottom: 0; }
td a { font-weight: 700; }

.toast-region { position: fixed; right: 1rem; bottom: 1rem; display: grid; gap: .5rem; z-index: 30; }
.toast { max-width: min(420px, calc(100vw - 2rem)); background: #183247; color: var(--text); border: 1px solid #52718f; padding: .85rem 1rem; border-radius: .7rem; box-shadow: var(--shadow); }
dialog { width: min(600px, calc(100% - 2rem)); max-height: calc(100vh - 2rem); overflow: auto; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
dialog::backdrop { background: rgb(0 0 0 / 68%); backdrop-filter: blur(3px); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

.filters { display: grid; grid-template-columns: minmax(220px, 2fr) repeat(2, minmax(150px, 1fr)) auto; gap: .85rem; align-items: end; }
.filters button { min-width: 7rem; }
.editor-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 1rem; align-items: start; }
.editor-grid > .card { min-width: 0; }
.case-form-grid { display: grid; grid-template-columns: 3fr 5fr 4fr; gap: .9rem; align-items: start; }
.case-form-grid > .field--full { grid-column: 1 / -1; }
.case-form-grid > .field--wide { grid-column: span 2; }
.check-field { display: flex; align-items: center; width: fit-content; min-height: 40px; padding: .45rem .7rem; border: 1px solid var(--border); border-radius: .65rem; background: rgb(7 17 28 / 48%); }
.check-field input { width: 1.1rem !important; height: 1.1rem; margin: 0 .25rem 0 0; }
.form-actions { display: flex; align-items: end; justify-content: space-between; gap: 1rem; padding-top: .3rem; border-top: 1px solid rgb(48 68 88 / 65%); }
.generation-actions { display: grid; grid-template-columns: minmax(280px, 520px) auto; align-items: end; justify-content: end; gap: .7rem; flex: 1; }
.model-picker { min-width: 0; }
.model-picker select { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: .8rem; }
.generation-usage { grid-column: 1 / -1; display: grid; gap: .55rem; padding: .7rem .8rem; border: 1px solid rgb(36 182 170 / 32%); border-radius: .65rem; background: rgb(36 182 170 / 7%); }
.generation-usage[hidden] { display: none; }
.generation-usage > strong { color: #a4e7e2; font-size: .82rem; }
.generation-metrics { display: grid; grid-template-columns: repeat(5, minmax(100px, 1fr)); gap: .5rem; margin: .65rem 0; }
.generation-metric { min-width: 0; padding: .5rem .6rem; border-radius: .5rem; background: rgb(7 17 28 / 52%); }
.generation-metric dt { color: var(--muted); font-size: .72rem; }
.generation-metric dd { margin: .16rem 0 0; color: var(--text); font-size: .86rem; font-weight: 700; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.generation-metric--total { background: rgb(36 182 170 / 12%); }
.generation-metric--total dd { color: #a4e7e2; }
.warning-list { display: grid; gap: .5rem; padding: 0; list-style: none; }
.warning-item { margin: 0; padding: .7rem .8rem; border: 1px solid rgb(213 162 61 / 30%); border-left: 4px solid #d5a23d; background: #2b261a; border-radius: .5rem; }
.warning-item.block { border-color: rgb(239 106 116 / 28%); border-left-color: var(--danger); background: #351d25; }
.option-list { display: grid; gap: .65rem; }
.option-row { display: grid; grid-template-columns: minmax(220px, 1fr) minmax(150px, 190px) repeat(3, auto); gap: .55rem; align-items: center; padding: .65rem; border: 1px solid rgb(48 68 88 / 70%); border-radius: .75rem; background: rgb(7 17 28 / 32%); }
.option-row button { min-height: 38px; padding: .52rem .65rem; font-size: .8rem; }
.option-row .badge { grid-column: 1 / -1; }
.generation-log { border-top: 1px solid var(--border); padding-top: .8rem; }
.generation-log summary { cursor: pointer; color: #c7d8e2; font-weight: 650; overflow-wrap: anywhere; }
.generation-log pre { white-space: pre-wrap; word-break: break-word; max-height: 320px; overflow: auto; padding: .9rem; background: #07111c; border: 1px solid #263c51; border-radius: .6rem; }
.structured-fields textarea { min-height: 150px; }
.structured-fields textarea:last-of-type { min-height: 100px; }
.subnavigation { position: sticky; top: var(--topbar-height, 82px); z-index: 8; flex-wrap: nowrap; padding: .55rem; overflow-x: auto; box-shadow: 0 8px 24px rgb(0 0 0 / 16%); }
.subnavigation a { flex: 0 0 auto; padding: .55rem .75rem; border-radius: .55rem; color: var(--muted); font-size: .88rem; font-weight: 650; text-decoration: none; white-space: nowrap; }
.subnavigation a:hover { color: var(--text); background: rgb(255 255 255 / 5%); }
.subnavigation a[aria-current="page"] { color: #d8fffa; background: rgb(36 182 170 / 14%); }

/* Alan türüne göre kendiliğinden sütunlanan genel form ızgarası. */
.field-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 245px), 1fr)); gap: .9rem 1rem; align-items: start; }
.field-grid > .field--full { grid-column: 1 / -1; }
.field-grid > .field--wide { grid-column: span 2; }
.field-grid > label > textarea { min-height: 120px; }
.form-footer {
  position: sticky;
  bottom: 0;
  z-index: 6;
  display: flex;
  justify-content: flex-end;
  gap: .75rem;
  padding: .8rem;
  border: 1px solid rgb(62 85 108 / 85%);
  border-radius: var(--radius);
  background: rgb(8 19 31 / 94%);
  box-shadow: 0 -10px 26px rgb(0 0 0 / 22%);
  backdrop-filter: blur(14px);
}
.form-footer button { min-width: 11rem; }

.screen-guard { border-color: rgb(213 162 61 / 48%); }
.screen-guard h2 { color: #f2d493; }
.screen-guard-tips { display: grid; gap: .5rem; margin: 0; padding-left: 1.2rem; color: #c5d3dc; font-size: .92rem; }
.screen-gauge { display: grid; gap: .45rem; }
.screen-gauge-text { color: var(--muted); font-size: .85rem; font-variant-numeric: tabular-nums; }
.screen-gauge-track { height: .5rem; overflow: hidden; border: 1px solid var(--border); border-radius: 999px; background: rgb(7 17 28 / 70%); }
.screen-gauge-fill { height: 100%; border-radius: 999px; background: linear-gradient(90deg, #d5a23d, var(--accent)); transition: width 180ms ease; }
.screen-guard[data-satisfied="true"] { border-color: rgb(36 182 170 / 55%); }
.screen-guard[data-satisfied="true"] .screen-gauge-fill { background: var(--accent); }

@media (max-width: 1180px) {
  .topbar-inner { grid-template-columns: auto 1fr auto; padding: .7rem 0 .55rem; }
  .navigation { grid-column: 1 / -1; grid-row: 2; justify-content: flex-start; margin: 0 -.2rem; padding: .15rem .2rem; }
  .editor-grid { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 900px) {
  .page, .page--wide { width: min(100% - 1.5rem, 760px); margin: 1.25rem auto; }
  .narrow { width: min(520px, calc(100% - 1.5rem)); margin-top: 2rem; }
  .filters { grid-template-columns: 1fr 1fr; }
  .filters > label:first-child { grid-column: 1 / -1; }
  .filters button { width: 100%; }
  .case-form-grid { grid-template-columns: 1fr 1fr; }
  .case-form-grid > .field--wide, .case-form-grid > .field--full { grid-column: 1 / -1; }
  .field-grid > .field--wide { grid-column: 1 / -1; }
  .form-actions { align-items: stretch; flex-direction: column; }
  .form-actions > button { width: 100%; }
  .generation-actions { width: 100%; grid-template-columns: minmax(0, 1fr) auto; }
  .generation-metrics { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .option-row { grid-template-columns: minmax(0, 1fr) minmax(140px, .7fr) repeat(3, auto); }
}

@media (max-width: 680px) {
  :root { font-size: 15px; }
  .topbar-inner { width: calc(100% - 1.25rem); grid-template-columns: 1fr auto; }
  .brand-subtitle { display: none; }
  .account-menu { gap: .35rem; }
  .user-chip { max-width: 6.5rem; }
  .navigation { padding-bottom: .35rem; }
  .navigation a { padding: .58rem .65rem; }
  .generation-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .generation-metric--total { grid-column: 1 / -1; }
  .page, .page--wide, .narrow { width: calc(100% - 1rem); margin-top: .9rem; }
  .card { padding: .9rem; border-radius: .8rem; }
  .page-header { align-items: stretch; }
  .page-header > button, .page-header > .button { width: 100%; }
  .cards { grid-template-columns: 1fr 1fr; gap: .65rem; }
  .filters, .case-form-grid, .field-grid { grid-template-columns: 1fr; }
  .form-footer { padding: .65rem; }
  .form-footer button { width: 100%; min-width: 0; }
  .filters > *, .case-form-grid > .field--wide, .case-form-grid > .field--full { grid-column: 1; }
  .generation-actions { grid-template-columns: 1fr; }
  .generation-actions button { width: 100%; }
  .option-row { grid-template-columns: 1fr 1fr; }
  .option-row > input { grid-column: 1 / -1; }
  .option-row button { width: 100%; }
  .option-row button.danger { grid-column: 1 / -1; }
  .subnavigation { margin-right: -.25rem; margin-left: -.25rem; }
  input, textarea, select { font-size: 16px; }
  .toast-region { right: .5rem; bottom: .5rem; }
}

@media (max-width: 420px) {
  .cards { grid-template-columns: 1fr; }
  .user-chip { display: none; }
  .brand { font-size: 1.08rem; }
  .logout-button { padding-inline: .55rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}
