:root {
  --teal: #1a8a9c;
  --teal-soft: #e6f3f5;
  --orange: #e84a1f;
  --orange-soft: #fdece6;
  --dark: #0b2a30;
  --ink: #16353b;
  --muted: #6a8185;
  --bg: #f4f7f7;
  --card: #ffffff;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'IBM Plex Sans Arabic', system-ui, sans-serif;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

h1, p { margin: 0; }

button { font: inherit; color: inherit; }

/* ---------- Login ---------- */

body.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 340px;
  padding: 40px 28px 28px;
  background: var(--card);
  border-radius: 24px;
  box-shadow: 0 8px 30px rgba(11, 42, 48, 0.07);
  text-align: center;
}

.login-logo { width: 190px; max-width: 80%; height: auto; }

.login-card form { margin-top: 32px; display: grid; gap: 12px; }

.pin {
  width: 100%;
  padding: 14px;
  font: inherit;
  font-size: 28px;
  letter-spacing: 0.4em;
  text-align: center;
  direction: ltr;
  border: 1.5px solid #d5e2e4;
  border-radius: 14px;
  background: #fbfdfd;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.pin::placeholder { color: #c3d3d6; }

.pin:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 4px rgba(26, 138, 156, 0.15);
}

.login-card button {
  padding: 14px;
  font-weight: 600;
  font-size: 16px;
  color: #fff;
  background: var(--teal);
  border: 0;
  border-radius: 14px;
  cursor: pointer;
}

.login-card button:hover { background: #157583; }

.login-error { color: var(--orange); font-size: 14px; font-weight: 500; }

/* ---------- Board ---------- */

.top,
.tabs,
.panels {
  max-width: 680px;
  margin-inline: auto;
  padding-inline: 20px;
}

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 68px;
}

.top-logo { height: 28px; width: auto; }

.top-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
}

.pill {
  flex: none;
  padding: 7px 12px;
  font-size: 14px;
  color: var(--muted);
  text-decoration: none;
  background: transparent;
  border: 0;
  border-radius: 999px;
  cursor: pointer;
}

.pill:hover { background: #e3ecee; color: var(--dark); }

.pill[aria-pressed='true'] { color: #fff; background: var(--orange); }

.who {
  padding-inline: 8px;
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.icon {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Admin tools show only in edit mode. */
.edit-only { display: none !important; }
body.is-editing .edit-only { display: flex !important; }

/* Horizontal scroller: vertical overflow hidden on purpose. */
.tabs {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  gap: 6px;
  padding-block: 10px;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  background: var(--bg);
}

.tabs::-webkit-scrollbar { display: none; }

.tab {
  flex: none;
  padding: 9px 16px;
  font-size: 15px;
  font-weight: 500;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.tab:hover { color: var(--dark); background: #e7eff0; }

.tab[aria-selected='true'] {
  color: #fff;
  background: var(--teal);
}

.tab:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; }

.panels { padding-top: 12px; padding-bottom: 64px; }

.panel {
  padding: 26px 20px 14px;
  background: var(--card);
  border-radius: 20px;
  box-shadow: 0 8px 30px rgba(11, 42, 48, 0.06);
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-inline: 8px;
}

.panel h1 {
  font-size: 22px;
  color: var(--dark);
}

.note {
  margin: 14px 8px 0;
  padding: 12px 14px;
  font-size: 14px;
  line-height: 1.7;
  color: #8a3216;
  background: var(--orange-soft);
  border-radius: 12px;
}

.todos {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
  display: grid;
  gap: 2px;
}

.todo-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.todo {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 12px 8px;
  text-align: start;
  background: transparent;
  border: 0;
  border-radius: 12px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.15s;
}

.todo:hover { background: #f3f8f8; }
.todo[aria-disabled='true'] { cursor: default; }
.todo[aria-disabled='true']:hover { background: transparent; }
.todo:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; }

.box {
  flex: none;
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  margin-top: 1px;
  border: 2px solid #b9cdd0;
  border-radius: 8px;
  background: #fff;
  transition: background 0.2s, border-color 0.2s;
}

.box svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: #fff;
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 24;
  stroke-dashoffset: 24;
  transition: stroke-dashoffset 0.25s ease 0.05s;
}

.todo.is-done .box { background: var(--teal); border-color: var(--teal); }
.todo.is-done .box svg { stroke-dashoffset: 0; }

.todo-body { display: grid; gap: 2px; min-width: 0; }

.todo-text {
  font-size: 16px;
  font-weight: 500;
  line-height: 1.6;
  transition: color 0.2s;
}

.todo.is-done .todo-text {
  color: var(--muted);
  text-decoration: line-through;
  text-decoration-color: rgba(26, 138, 156, 0.6);
  text-decoration-thickness: 2px;
}

.tag {
  display: inline-block;
  margin-inline-start: 6px;
  padding: 0 10px;
  font-size: 12px;
  font-weight: 600;
  color: var(--orange);
  background: var(--orange-soft);
  border-radius: 999px;
  vertical-align: 2px;
}

.num { color: var(--muted); font-weight: 600; }

.todo-detail { color: var(--muted); font-size: 14px; line-height: 1.6; }

.tools {
  flex: none;
  gap: 2px;
}

.tools button {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
}

.tools button:hover { color: var(--dark); background: #eaf1f2; }
.tools button.danger:hover { color: var(--orange); background: var(--orange-soft); }

.add-todo,
.tab-add {
  align-items: center;
  gap: 6px;
  cursor: pointer;
}

.add-todo {
  margin: 6px 0 4px;
  padding: 10px 12px;
  font-size: 15px;
  font-weight: 500;
  color: var(--teal);
  background: transparent;
  border: 0;
  border-radius: 12px;
}

.add-todo:hover { background: var(--teal-soft); }

.tab-add { color: var(--teal); }

.empty { padding: 40px 20px; text-align: center; color: var(--muted); }

/* ---------- Dialog ---------- */

.dialog {
  width: min(440px, calc(100% - 32px));
  max-height: calc(100% - 48px);
  padding: 24px;
  color: var(--ink);
  border: 0;
  border-radius: 20px;
  box-shadow: 0 24px 60px rgba(11, 42, 48, 0.25);
}

.dialog::backdrop { background: rgba(11, 42, 48, 0.45); }

.dialog h2 { margin: 0; font-size: 19px; color: var(--dark); }
.dialog h3 { margin: 20px 0 0; font-size: 15px; color: var(--dark); }

.dialog-text { margin-top: 8px; color: var(--muted); line-height: 1.7; }

.fields { display: grid; gap: 14px; margin-top: 16px; }

.field { display: grid; gap: 6px; font-size: 14px; font-weight: 500; }

.field input,
.field textarea,
.field select {
  width: 100%;
  padding: 11px 12px;
  font: inherit;
  font-size: 16px;
  font-weight: 400;
  color: var(--ink);
  border: 1.5px solid #d5e2e4;
  border-radius: 12px;
  background: #fbfdfd;
  outline: none;
  resize: vertical;
}

.field input:focus,
.field textarea:focus,
.field select:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 4px rgba(26, 138, 156, 0.15);
}

.check-field {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 15px;
  cursor: pointer;
}

.check-field input { width: 18px; height: 18px; accent-color: var(--teal); }

.form-error { margin-top: 12px; color: var(--orange); font-size: 14px; font-weight: 500; }
.form-error:empty { display: none; }

.dialog-actions { display: flex; gap: 8px; margin-top: 20px; }

.btn {
  padding: 11px 20px;
  font-weight: 600;
  color: #fff;
  background: var(--teal);
  border: 0;
  border-radius: 12px;
  cursor: pointer;
}

.btn:disabled { opacity: 0.6; cursor: wait; }
.btn-danger { background: var(--orange); }
.btn-ghost { color: var(--muted); background: #eef3f4; }

.pin-list {
  list-style: none;
  margin: 14px 0 0;
  padding: 0;
  display: grid;
  gap: 6px;
}

.pin-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: #f5f9f9;
  border-radius: 12px;
}

.pin-name { flex: 1; min-width: 0; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.role {
  padding: 1px 10px;
  font-size: 12px;
  font-weight: 600;
  border-radius: 999px;
}

.role-admin { color: #fff; background: var(--teal); }
.role-editor { color: var(--teal); background: var(--teal-soft); }
.role-visitor { color: var(--muted); background: #e8eeef; }

.pin-del {
  padding: 4px 10px;
  font-size: 13px;
  color: var(--orange);
  background: transparent;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
}

.pin-del:hover:not(:disabled) { background: var(--orange-soft); }
.pin-del:disabled { color: var(--muted); cursor: default; }
.pin-del[data-armed='1'] { color: #fff; background: var(--orange); }

@media (max-width: 520px) {
  .who { display: none; }
  .tools button { width: 30px; height: 30px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
