:root {
  color-scheme: dark;
  --sea: #102c38;
  --ink: #19333c;
  --paper: #faf8ef;
  --light: #e5f0eb;
  --muted: #b3cbd0;
  --line: #acc9ce40;
  --error: #ffd4ba;
  font-family: "MiSans", "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  line-height: 1.55;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--light);
  background: radial-gradient(ellipse at 78% 0%, #275460 0, transparent 52%), linear-gradient(160deg, var(--sea), #0b222e 72%);
}
main { max-width: 1100px; padding: 0 clamp(16px, 4vw, 40px) 28px; margin-inline: auto; }
button, input, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { opacity: .52; cursor: default; }
button, a, textarea, input { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 2px solid #61ad9f; outline-offset: 3px; }
a { color: inherit; text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, p { margin: 0; }

.topbar, .panel-head, .panel-foot, .dock-footer, .dialog-head {
  display: flex; align-items: center; justify-content: space-between; gap: .75rem;
}
.topbar { min-height: 62px; border-bottom: 1px solid var(--line); font-size: .875rem; color: var(--muted); }
.connection-state { display: inline-flex; align-items: center; gap: .5rem; white-space: nowrap; }
.connection-state::before { content: ""; width: .5rem; height: .5rem; border-radius: 50%; background: #839ba3; }
.connection-state.online::before { background: #9bd6bd; box-shadow: 0 0 0 3px #9bd6bd20; }
.masthead {
  display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: 1rem;
  padding-top: clamp(22px, 5vw, 52px);
}
.masthead h1 {
  font-family: "Source Han Serif SC", "Noto Serif CJK SC", "Songti SC", SimSun, serif;
  font-size: clamp(2.55rem, 6vw, 4.65rem); font-weight: 800; line-height: 1.15; letter-spacing: .035em;
}
.masthead p { color: var(--muted); margin-top: .65rem; }
.pair-actions, .dialog-actions { display: flex; flex-wrap: wrap; align-items: center; gap: .52rem 1rem; }
.water { flex: 0 0 100%; height: 21px; position: relative; overflow: hidden; isolation: isolate; }
.water::before, .water::after {
  content: ""; position: absolute; inset: auto 0 4px; height: 1px;
  background: linear-gradient(90deg, transparent, #9cc8c38c 18%, #9cc8c349 68%, transparent);
}
.water::after { inset: auto 4% 1px 12%; opacity: .4; }
.bottle {
  position: absolute; z-index: 1; left: 0; top: 5px; width: 20px; height: 10px;
  border: 1px solid #b9e2ca; border-radius: 3px 5px 5px 3px; background: #34665f; opacity: 0;
}
.bottle::before { content: ""; position: absolute; left: -4px; top: 2px; width: 4px; height: 4px; background: #ddc09a; border-radius: 1px; }
.bottle.sailing { animation: drift 1.5s ease-out both; }
@keyframes drift {
  0% { left: 3%; opacity: 0; transform: rotate(-11deg); }
  18% { opacity: 1; }
  55% { transform: rotate(6deg); }
  80% { opacity: .84; }
  100% { left: calc(100% - 25px); opacity: 0; transform: rotate(-5deg); }
}
@media (prefers-reduced-motion: reduce) { .bottle.sailing { animation: none; } }

.notice { color: #cfe4df; font-size: .9rem; margin: 0 0 .72rem; overflow-wrap: anywhere; }
.notice:empty { display: none; }
.notice.error, .dialog-feedback.error { color: var(--error); }
.workspace { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: clamp(12px, 2.3vw, 23px); }
.panel {
  display: flex; flex-direction: column; min-width: 0; min-height: 330px;
  padding: clamp(14px, 2.6vw, 26px); border: 1px solid var(--line); border-radius: 17px;
  background: #173a49; box-shadow: 0 12px 32px #04182136;
}
.panel-head { margin-bottom: .9rem; }
.panel h2, .dialog-head h2 { font-size: 1.2rem; font-weight: 700; letter-spacing: .03em; }
.panel-foot { margin-top: auto; padding-top: .85rem; color: var(--muted); font-size: .78rem; }
.panel-foot span { overflow-wrap: anywhere; }
.panel textarea {
  display: block; flex: 1 0 auto; width: 100%; min-height: 180px; padding: .83rem;
  color: inherit; background: #0d2d3b; border: 1px solid var(--line); border-radius: 9px;
  resize: vertical; overflow-wrap: anywhere;
}
textarea::placeholder { color: #afc5ca; }
#count.over { color: var(--error); }
.receive { color-scheme: light; color: var(--ink); background: var(--paper); border-color: #fbf8ee; }
.receive textarea {
  color: var(--ink); background: transparent; border: 0; padding: .24rem .15rem .5rem;
  min-height: 140px; flex: none; height: 180px;
}
.receive .panel-foot { color: #526568; border-top: 1px solid #a1aba752; }
.receive-actions {
  display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: .35rem .85rem;
}
.receive-actions .link-button { white-space: nowrap; }
.received-links {
  max-height: min(42vh, 330px); overflow: auto; scrollbar-width: thin;
  padding: 4px; margin: -4px -4px .55rem;
}
.received-text {
  padding: .24rem .15rem .5rem;
  white-space: pre-wrap; overflow-wrap: anywhere; tab-size: 4;
}
.received-text a {
  color: #245e55; text-decoration: underline; text-underline-offset: .18em;
}
.received-text a:hover { color: #153f39; }
.link-cards { display: grid; gap: .55rem; }
.link-card {
  display: flex; align-items: center; gap: .75rem; justify-content: space-between;
  min-height: 58px; padding: .72rem .88rem;
  border: 1px solid #c5d7cd; border-radius: 10px;
  background: #edf3ed; color: #214d45;
}
.link-card:hover { text-decoration: none; background: #e1eee6; border-color: #8faf9e; }
.link-card-label { display: grid; min-width: 0; gap: .16rem; overflow: hidden; }
.link-card-label strong, .link-card-path {
  overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
}
.link-card-label strong { font-size: .96rem; }
.link-card-path { font-size: .78rem; color: #4a625b; }
.link-card-arrow {
  flex: 0 0 auto; display: grid; place-items: center; width: 27px; height: 27px;
  border-radius: 50%; background: #dce9e0; font-size: .9rem;
}
.empty { color: #526568; font-size: .92rem; padding: .4rem 0 1.2rem; }
.primary, .light {
  min-height: 42px; padding: .48rem .9rem; border: 1px solid transparent; border-radius: 8px;
  color: #102e33; background: #c2e0cf; font-weight: 700; white-space: nowrap;
}
.primary:hover:not(:disabled) { background: #d9efde; }
.light { background: #e7f0e9; }
.light:hover:not(:disabled) { background: #f4faf5; }
.receive .primary { color: #fff; background: #285b55; }
.receive .primary:hover:not(:disabled) { background: #1b4943; }
.link-button { padding: .32rem 0; min-height: 36px; color: inherit; background: transparent; border: 0; font-size: .87rem; }
.link-button:hover:not(:disabled) { text-decoration: underline; text-underline-offset: .2em; }
.dock-footer { flex-wrap: wrap; color: var(--muted); font-size: .82rem; margin-top: .95rem; }

dialog {
  width: min(94vw, 420px); max-height: calc(100dvh - 24px); margin: auto; padding: clamp(16px, 4.5vw, 25px);
  color: var(--light); background: #163745; border: 1px solid #597580; border-radius: 16px;
  box-shadow: 0 20px 80px #071820ab;
}
dialog::backdrop { background: #06141bd1; }
.close { width: 38px; height: 38px; border: 0; border-radius: 8px; color: inherit; background: #ffffff0e; font-size: 1.45rem; }
.dialog-head { margin-bottom: .8rem; }
dialog section > p, .dialog-note, .dialog-feedback, .field { color: var(--muted); font-size: .9rem; }
.qr-box {
  display: grid; place-items: center; margin: .75rem auto .4rem; width: min(100%, 220px); min-height: 160px;
  background: #fff; color: var(--ink); border-radius: 9px; padding: 8px; text-align: center; font-size: .85rem;
}
.qr-box canvas { display: block; width: 100%; height: auto; image-rendering: pixelated; }
#digits { text-align: center; color: var(--light); font: 700 clamp(1.7rem, 6vw, 2.15rem)/1.25 ui-monospace, Consolas, monospace; letter-spacing: .12em; }
.dialog-note { text-align: center; margin-top: .3rem; }
.dialog-actions { margin-top: .95rem; }
.dialog-feedback { margin-top: .6rem; }
.dialog-feedback:empty { display: none; }
.field { display: block; margin-bottom: .38rem; }
#code {
  width: 100%; padding: .7rem .8rem; color: var(--light); background: #0b2734;
  border: 1px solid #79929a; border-radius: 8px; font: 1.1rem ui-monospace, Consolas, monospace; letter-spacing: .08em;
}
.legacy-toggle { margin-top: .28rem; }

@media (max-width: 660px) {
  .topbar { min-height: 52px; }
  .workspace { grid-template-columns: minmax(0, 1fr); grid-template-areas: "compose" "receive"; }
  .workspace.has-mail { grid-template-areas: "receive" "compose"; }
  .compose { grid-area: compose; }
  .receive { grid-area: receive; min-height: 0; position: relative; }
  .receive .panel-head { margin-bottom: .48rem; }
  .receive textarea { height: 112px; min-height: 86px; }
  .panel-foot, .dock-footer { gap: .42rem; }
}
