/* Phone: the participant's copy. Paper first, the AI's ink on top. */

body {
  min-height: 100dvh;
  background: var(--paper);
}

.top {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: var(--navy);
  color: #fff;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.82rem;
  font-weight: 500;
  letter-spacing: 0.01em;
  min-width: 0;
}
.brand span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.top .k-mark {
  height: 28px;
}
.top .lang-switch {
  color: var(--mist);
  flex: none;
}
.top .lang-switch button {
  color: #fff;
}

.conn {
  position: sticky;
  top: 52px;
  z-index: 4;
  margin: 0;
  padding: 6px 16px;
  background: var(--amber);
  color: var(--navy);
  font-size: 0.85rem;
  font-weight: 600;
  text-align: center;
}

.app {
  max-width: 560px;
  margin: 0 auto;
  padding: 22px 18px calc(40px + env(safe-area-inset-bottom));
}

.view {
  animation: view-in 360ms var(--ease-out) both;
}
@keyframes view-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}

.eyebrow {
  margin: 0 0 10px;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-text);
}
:lang(ar) .eyebrow {
  letter-spacing: 0;
  font-size: 0.9rem;
}

h1,
.q-text {
  font-family: var(--f-display);
  font-weight: 500;
  color: var(--navy);
  margin: 0;
}
h1 {
  font-size: clamp(1.6rem, 7.4vw, 2.05rem);
  line-height: 1.16;
  letter-spacing: -0.01em;
}
.q-text {
  font-size: clamp(1.18rem, 5.3vw, 1.4rem);
  line-height: 1.32;
}
:lang(ar) h1,
:lang(ar) .q-text {
  line-height: 1.5;
  letter-spacing: 0;
}

.lede {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 1.02rem;
}

/* ------------------------------------------------------------ forms */

.field {
  margin-top: 30px;
}
.field label {
  display: block;
  font-weight: 600;
  font-size: 0.95rem;
  margin-bottom: 4px;
}
.line-input {
  width: 100%;
  border: 0;
  border-bottom: 2px solid var(--paper-line);
  background: transparent;
  padding: 10px 2px 8px;
  font-family: var(--f-hand);
  font-size: 1.7rem;
  font-weight: 700;
  color: var(--navy);
  border-radius: 0;
  transition: border-color 160ms;
}
.line-input:focus {
  outline: none;
  border-bottom-color: var(--ink);
}
.help {
  margin: 8px 0 0;
  font-size: 0.88rem;
  color: var(--muted);
}
.error {
  margin: 10px 0 0;
  color: var(--danger);
  font-weight: 600;
  font-size: 0.92rem;
}

.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  min-height: 56px;
  margin-top: 26px;
  border: 0;
  border-radius: 12px;
  background: var(--navy);
  color: #fff;
  font-weight: 600;
  font-size: 1.05rem;
  letter-spacing: 0.01em;
  transition:
    transform 120ms,
    background 160ms,
    opacity 160ms;
}
.btn:active {
  transform: scale(0.985);
}
.btn[disabled] {
  opacity: 0.45;
  cursor: not-allowed;
}
.btn.secondary {
  background: transparent;
  color: var(--navy);
  border: 2px solid var(--navy);
  min-height: 48px;
  margin-top: 12px;
}
a.btn {
  text-decoration: none;
}

/* ------------------------------------------------------------ lobby */

.lobby-card {
  margin-top: 26px;
  padding: 20px 20px 18px;
}
.lobby-card p {
  margin: 0;
}
.lobby-card .tip {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px dashed var(--paper-line);
  color: var(--muted);
  font-size: 0.95rem;
}
.pulse-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--ink);
  margin-inline-end: 8px;
  vertical-align: middle;
  animation: pulse 1.6s ease-in-out infinite;
}
@keyframes pulse {
  50% {
    opacity: 0.25;
    transform: scale(0.8);
  }
}

/* ------------------------------------------------------------ composer */

.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  margin-top: 22px;
  padding: 4px;
  gap: 4px;
  background: var(--paper-shade);
  border-radius: 12px;
}
.tabs button {
  min-height: 44px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--muted);
}
.tabs button[aria-selected='true'] {
  background: #fff;
  color: var(--navy);
  box-shadow: 0 1px 3px rgba(28, 33, 80, 0.14);
}

.paper-input {
  position: relative;
  margin-top: 14px;
  padding: 0;
  overflow: hidden;
}
.paper-input::before {
  /* the margin line of an exam copy */
  content: '';
  position: absolute;
  inset-block: 0;
  inset-inline-start: 30px;
  width: 1px;
  background: rgba(32, 173, 174, 0.35);
  pointer-events: none;
}
.paper-input textarea {
  --line: 1.9rem;
  display: block;
  width: 100%;
  min-height: calc(var(--line) * 6 + 0.5rem);
  border: 0;
  resize: none;
  /* ruled lines that scroll with the text and sit under each line of it */
  background-color: transparent;
  background-image: linear-gradient(to bottom, transparent calc(var(--line) - 1px), var(--paper-line) calc(var(--line) - 1px));
  background-size: 100% var(--line);
  background-position: 0 0.5rem;
  background-attachment: local;
  line-height: var(--line);
  padding: 0.5rem 16px var(--line) 42px;
  font-size: 1.05rem;
  color: var(--text);
}
[dir='rtl'] .paper-input textarea {
  padding: 0.5rem 42px var(--line) 16px;
}
.paper-input textarea:focus {
  outline: none;
}
.paper-input:focus-within {
  box-shadow:
    0 0 0 2px var(--ink),
    0 10px 30px -12px rgba(16, 20, 64, 0.35);
}
.count {
  position: absolute;
  inset-block-end: 6px;
  inset-inline-end: 12px;
  font-size: 0.75rem;
  color: var(--muted);
}

.photo-drop {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  min-height: 210px;
  margin-top: 14px;
  padding: 22px;
  border: 2px dashed var(--mist);
  border-radius: var(--radius);
  background: #fff;
  text-align: center;
  font-weight: 600;
  color: var(--navy);
}
.photo-drop svg {
  width: 44px;
  height: 44px;
  color: var(--ink);
}
.photo-drop small {
  font-weight: 400;
  color: var(--muted);
  max-width: 28ch;
}
.photo-preview {
  margin-top: 14px;
  padding: 10px;
  transform: rotate(-0.6deg);
}
.photo-preview img {
  width: 100%;
  max-height: 40vh;
  object-fit: contain;
  border-radius: 4px;
  background: var(--paper-shade);
}

/* ------------------------------------------------------------ marking */

.copy {
  margin-top: 20px;
  padding: 16px 18px 18px;
  position: relative;
}
.copy-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  min-height: 56px;
}
.copy-head .label {
  margin: 6px 0 0;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}
:lang(ar) .copy-head .label {
  letter-spacing: 0;
}
.copy .mark {
  font-size: 2.9rem;
  margin: 12px 18px 6px;
}
.copy .verdict {
  margin: 4px 0 6px;
  font-size: 1.35rem;
}
.copy .answer {
  margin: 8px 0 0;
  font-size: 1.04rem;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.read-label {
  margin: 16px 0 0;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}
:lang(ar) .read-label {
  letter-spacing: 0;
  font-size: 0.9rem;
}
.read-label + .answer {
  margin-top: 4px;
}
.copy .thumb {
  margin-top: 10px;
  max-height: 220px;
  object-fit: contain;
  border-radius: 4px;
}

.pen-line {
  height: 26px;
  margin: 14px 0 4px;
  color: var(--ink);
}
.pen-line path {
  fill: none;
  stroke: currentColor;
  stroke-width: 2.6;
  stroke-linecap: round;
  stroke-dasharray: 1;
  animation: scribble 2.2s ease-in-out infinite;
}
@keyframes scribble {
  0% {
    stroke-dashoffset: 1;
  }
  60% {
    stroke-dashoffset: 0;
  }
  100% {
    stroke-dashoffset: -1;
  }
}

.steps {
  list-style: none;
  margin: 18px 0 0;
  padding: 0;
  display: grid;
  gap: 10px;
}
.steps li {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  transition: color 300ms;
}
.steps li::before {
  content: '';
  flex: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid var(--paper-line);
  transition:
    background 300ms,
    border-color 300ms;
}
.steps li.on {
  color: var(--navy);
  font-weight: 600;
}
.steps li.on::before {
  border-color: var(--ink);
  background: radial-gradient(circle, var(--ink) 0 45%, transparent 50%);
}

/* ------------------------------------------------------------ result */

.notes {
  margin-top: 22px;
  display: grid;
  gap: 18px;
}
.notes h2 {
  margin: 0 0 8px;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}
:lang(ar) .notes h2 {
  letter-spacing: 0;
  font-size: 0.92rem;
}
.notes ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}
.notes li {
  display: grid;
  grid-template-columns: 22px 1fr;
  gap: 10px;
  align-items: start;
}
.notes li svg {
  width: 22px;
  height: 22px;
  margin-top: 1px;
}
.notes .good svg {
  color: var(--ink);
}
.notes .fix .hl {
  background: linear-gradient(transparent 56%, var(--amber-soft) 56%, var(--amber-soft) 94%, transparent 94%);
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
}
.notes .fix svg {
  color: #c98a12;
}
.ten {
  padding: 14px 16px;
  border-inline-start: 4px solid var(--ink);
  background: #fff;
  border-radius: 0 10px 10px 0;
}
[dir='rtl'] .ten {
  border-radius: 10px 0 0 10px;
}
.ten p {
  margin: 0;
}

.status-chip {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-top: 24px;
  padding: 12px 16px;
  border-radius: 12px;
  background: var(--navy);
  color: #fff;
  font-weight: 600;
}
.status-chip .hint {
  font-weight: 400;
  color: var(--mist);
  font-size: 0.9rem;
}

.banner {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 18px;
  padding: 12px 14px;
  border-radius: 12px;
  background: rgba(32, 173, 174, 0.12);
  color: var(--navy);
  font-weight: 600;
}

/* ------------------------------------------------------------ rank */

.rank {
  margin-top: 26px;
  padding: 26px 22px;
  text-align: center;
}
.rank .big {
  font-family: var(--f-display);
  font-weight: 700;
  font-size: 4.6rem;
  line-height: 1;
  color: var(--navy);
  direction: ltr;
}
.rank .of {
  margin-top: 6px;
  color: var(--muted);
  font-size: 1.05rem;
}
.rank .total {
  margin-top: 18px;
  font-weight: 600;
  font-size: 1.15rem;
}
.rank .gain {
  margin-top: 6px;
  font-size: 1.4rem;
}

.center-note {
  margin-top: 26px;
  padding: 22px;
  text-align: center;
  color: var(--muted);
}

/* ------------------------------------------------------------ join: a marked example */

.sample {
  margin: 34px 0 0;
}
.sample figcaption {
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 10px;
}
:lang(ar) .sample figcaption {
  letter-spacing: 0;
  font-size: 0.9rem;
}
.sample-sheet {
  padding: 14px 16px 16px;
  transform: rotate(-0.8deg);
}
.sample-sheet .copy-head {
  align-items: center;
  min-height: 0;
}
.sample-sheet .verdict {
  margin: 0;
  font-size: 1.2rem;
}
.sample-sheet .mark {
  font-size: 2rem;
  margin: 8px 14px 6px;
}
.sample-sheet .answer {
  margin: 8px 0 0;
  font-size: 0.98rem;
  color: var(--text);
}
