:root {
  --ground: #e4eae6;
  --ink: #1b211e;
  --mute: #66706a;
  --faint: #8b958e;
  --line: #c9d2cc;
  --celadon: #2c5948;
  --celadon-deep: #23483a;
  --paper: #fffefb;
  --phone: #242826;
  --cinnabar: #9c3a32;
  --sans: "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Microsoft YaHei", system-ui, sans-serif;
  --serif: "Songti SC", "STSong", "Source Han Serif SC", "Noto Serif SC", "SimSun", serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, "PingFang SC", monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--ground);
  color: var(--ink);
  font-family: var(--sans);
  color-scheme: light;
  -webkit-font-smoothing: antialiased;
}

body {
  min-height: 100%;
}

::selection {
  background: rgba(44, 89, 72, 0.16);
}

.app {
  height: 100%;
  display: flex;
  flex-direction: column;
  padding: 18px 28px 24px;
}

.bar {
  display: flex;
  align-items: center;
  gap: 28px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
}

.mark,
.seal {
  width: 14px;
  height: 14px;
  border: 1.5px solid var(--celadon);
  border-radius: 50%;
  box-shadow: inset 0 0 0 2.5px var(--ground), inset 0 0 0 5px var(--celadon);
}

.copy .seal {
  width: 12px;
  height: 12px;
  border-color: currentColor;
  box-shadow: inset 0 0 0 2.5px var(--celadon), inset 0 0 0 4.5px currentColor;
}

.name {
  font-family: var(--serif);
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 0.12em;
  line-height: 1;
}

.tools {
  display: flex;
  align-items: center;
  gap: 18px;
  flex: 1;
  min-width: 0;
}

.field,
.switch,
.ghost,
.copy {
  font-size: 13px;
  color: var(--mute);
}

.field,
.switch {
  display: flex;
  align-items: center;
  gap: 8px;
}

.field span,
.switch span {
  letter-spacing: 0.06em;
}

select,
.ghost,
.copy {
  font: inherit;
  color: var(--ink);
}

.actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
}

select {
  appearance: none;
  cursor: pointer;
  min-width: 128px;
  padding: 6px 28px 6px 10px;
  background: rgba(255, 254, 251, 0.7) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='none' stroke='%2366706A' stroke-width='1.4' d='M1.5 1.5L6 6l4.5-4.5'/%3E%3C/svg%3E") no-repeat right 10px center;
  border: 1px solid var(--line);
  border-radius: 5px;
}

.switch input {
  appearance: none;
  width: 28px;
  height: 16px;
  margin: 0;
  background: #d3dbd6;
  border-radius: 99px;
  position: relative;
  cursor: pointer;
}

.switch input::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 12px;
  height: 12px;
  background: #fff;
  border-radius: 50%;
}

.switch input:checked {
  background: var(--celadon);
}

.switch input:checked::after {
  left: 14px;
}

.ghost,
.copy {
  border: 0;
  cursor: pointer;
}

.ghost {
  padding: 6px 12px;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 5px;
}

.ghost:hover {
  border-color: #b3beb7;
  color: var(--ink);
}

.copy {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px 7px 12px;
  background: var(--celadon);
  color: #f3f7f5;
  border-radius: 5px;
  letter-spacing: 0.08em;
}

.copy:hover {
  background: var(--celadon-deep);
}

.copy.is-done .seal {
  box-shadow: inset 0 0 0 6px currentColor;
}

select:focus-visible,
.ghost:focus-visible,
.copy:focus-visible,
.switch input:focus-visible,
.draft-field input:focus-visible {
  outline: 2px solid var(--celadon);
  outline-offset: 2px;
}

.work {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 400px;
  gap: 28px;
  padding-top: 18px;
}

.col {
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.col-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  min-height: 28px;
  padding: 0 2px 10px;
}

.slab {
  margin: 0;
  font-size: 11px;
  letter-spacing: 0.18em;
  color: var(--faint);
}

.hint {
  font-size: 11px;
  letter-spacing: 0.12em;
  color: var(--mute);
}

.sheet {
  flex: 1;
  min-height: 0;
  display: flex;
  background: var(--paper);
  border-radius: 2px;
  box-shadow: 0 1px 0 rgba(27, 33, 30, 0.04), 0 16px 40px rgba(27, 33, 30, 0.06);
}

#source {
  flex: 1;
  width: 100%;
  resize: none;
  border: 0;
  padding: 22px 24px;
  background: transparent;
  color: var(--ink);
  font: 14px/1.75 var(--mono);
  outline: none;
}

#source:focus-visible {
  outline: none;
}

.sheet:focus-within {
  box-shadow: 0 1px 0 rgba(27, 33, 30, 0.04), 0 16px 40px rgba(27, 33, 30, 0.08);
}

.proof {
  flex: 1;
  min-height: 0;
  display: flex;
  justify-content: center;
}

.phone {
  width: 360px;
  height: 100%;
  max-height: calc(100vh - 132px);
  display: flex;
  flex-direction: column;
  padding: 10px 10px 8px;
  background: var(--phone);
  border-radius: 28px;
  box-shadow: 0 18px 48px rgba(27, 33, 30, 0.14);
}

.phone-cap,
.phone-home {
  flex: none;
  align-self: center;
  background: #111413;
  border-radius: 99px;
}

.phone-cap {
  width: 72px;
  height: 5px;
  margin-bottom: 8px;
}

.phone-home {
  width: 88px;
  height: 4px;
  margin-top: 7px;
}

.phone-screen {
  flex: 1;
  min-height: 0;
  overflow: auto;
  background: #fff;
  border-radius: 20px;
  padding: 26px 18px 48px;
}

.phone-screen::-webkit-scrollbar,
#source::-webkit-scrollbar {
  width: 8px;
}

#source::-webkit-scrollbar-thumb {
  background: #d7ddd8;
  border-radius: 99px;
}

.phone-screen::-webkit-scrollbar {
  width: 0;
}

.fail {
  margin: 0;
  color: var(--cinnabar);
  font-size: 14px;
  line-height: 1.7;
}

.drop {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(228, 234, 230, 0.88);
  opacity: 0;
  pointer-events: none;
  z-index: 20;
}

.drop p {
  margin: 0;
  font-family: var(--serif);
  font-size: 22px;
  letter-spacing: 0.18em;
  color: var(--celadon);
}

body.is-dragging .drop {
  opacity: 1;
}

.draft-mask {
  position: fixed;
  inset: 0;
  display: none;
  place-items: center;
  background: rgba(228, 234, 230, 0.88);
  z-index: 24;
}

.draft-mask.is-open {
  display: grid;
}

.draft-card {
  width: min(420px, calc(100% - 32px));
  padding: 22px 24px 20px;
  background: var(--paper);
  box-shadow: 0 16px 40px rgba(27, 33, 30, 0.08);
}

.draft-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 14px 0 0;
  font-size: 12px;
  letter-spacing: 0.08em;
  color: var(--mute);
}

.draft-field input[type="text"] {
  font: 14px/1.5 var(--sans);
  padding: 8px 10px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
}

.draft-field input[type="file"] {
  font: 13px/1.5 var(--sans);
  color: var(--ink);
}

.draft-hint {
  min-height: 1.5em;
  margin: 14px 0 0;
  font-size: 13px;
  color: var(--mute);
}

.draft-hint.is-fail {
  color: var(--cinnabar);
}

.draft-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
}

@media (max-width: 980px) {
  .app { padding: 14px 16px 16px; }
  .work { grid-template-columns: 1fr; gap: 20px; }
  .phone { width: min(360px, 100%); max-height: 72vh; }
}

@media (max-width: 720px) {
  .bar {
    flex-wrap: wrap;
    gap: 12px 16px;
  }

  .tools {
    order: 3;
    flex: 1 0 100%;
    flex-wrap: wrap;
    gap: 12px;
  }

  .actions { margin-left: auto; }

  .name { letter-spacing: 0.08em; }
}

@media (prefers-reduced-motion: reduce) {
  .switch input::after,
  .copy,
  .drop {
    transition: none;
  }
}

@media (prefers-reduced-motion: no-preference) {
  .switch input,
  .switch input::after,
  .copy,
  .copy .seal,
  .drop,
  .ghost {
    transition: background-color 160ms ease, border-color 160ms ease, color 160ms ease, box-shadow 160ms ease, left 160ms ease, opacity 160ms ease;
  }
}
