:root {
  color-scheme: light;
  --background: #f5f4ef;
  --surface: #fffefa;
  --surface-muted: #efeee8;
  --ink: #1c211d;
  --ink-soft: #626760;
  --ink-faint: #8d918b;
  --line: #deddd6;
  --line-strong: #c9c8c0;
  --accent: #1e5c3e;
  --accent-hover: #174c33;
  --accent-soft: #e1ece5;
  --danger: #a33a31;
  --danger-soft: #f5e6e3;
  --on-accent: #ffffff;
  --field: #ffffff;
  --ambient: rgb(255 255 255 / 75%);
  --login-surface: rgb(255 254 250 / 90%);
  --header-surface: rgb(245 244 239 / 86%);
  --line-translucent: rgb(222 221 214 / 80%);
  --focus-ring: rgb(30 92 62 / 28%);
  --focus-shadow: rgb(30 92 62 / 12%);
  --drop-surface: rgb(239 246 241 / 95%);
  --skeleton-base: #e9e8e2;
  --skeleton-shine: #f3f2ed;
  --toast-surface: #252a26;
  --shadow-card: 0 1px 2px rgb(28 33 29 / 4%), 0 12px 36px rgb(28 33 29 / 5%);
  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 22px;
  --content-width: 760px;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-synthesis: none;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --background: #101411;
  --surface: #181d19;
  --surface-muted: #232a24;
  --ink: #edf2ed;
  --ink-soft: #b1bbb3;
  --ink-faint: #8f9b92;
  --line: #303831;
  --line-strong: #465148;
  --accent: #79c99c;
  --accent-hover: #8bd6aa;
  --accent-soft: #1c3727;
  --danger: #ff9c92;
  --danger-soft: #442522;
  --on-accent: #0c2115;
  --field: #131814;
  --ambient: rgb(64 94 72 / 20%);
  --login-surface: rgb(24 29 25 / 94%);
  --header-surface: rgb(16 20 17 / 88%);
  --line-translucent: rgb(48 56 49 / 82%);
  --focus-ring: rgb(121 201 156 / 35%);
  --focus-shadow: rgb(121 201 156 / 14%);
  --drop-surface: rgb(23 47 33 / 96%);
  --skeleton-base: #1d231e;
  --skeleton-shine: #2a322b;
  --toast-surface: #e4ebe5;
  --shadow-card: 0 1px 2px rgb(0 0 0 / 20%), 0 18px 48px rgb(0 0 0 / 24%);
}

* { box-sizing: border-box; }

html { min-width: 320px; background: var(--background); }

body {
  margin: 0;
  min-height: 100dvh;
  color: var(--ink);
  background:
    radial-gradient(circle at 50% -20%, var(--ambient) 0, transparent 42%),
    var(--background);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  transition: color 180ms ease, background-color 180ms ease;
}

button, input, textarea { font: inherit; }
button, a, label[for] { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
button { color: inherit; }
a { color: inherit; }
img { display: block; max-width: 100%; }
[hidden] { display: none !important; }

:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 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;
}

.skip-link {
  position: fixed;
  z-index: 1000;
  top: 12px;
  left: 12px;
  padding: 10px 14px;
  border-radius: 8px;
  color: white;
  background: var(--accent);
  transform: translateY(-150%);
}
.skip-link:focus { transform: translateY(0); }

.icon {
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  color: var(--ink);
  font-size: 18px;
  font-weight: 680;
  letter-spacing: -0.02em;
  text-decoration: none;
}

.brand-mark {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 5px var(--accent-soft);
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.loading-screen {
  position: fixed;
  inset: 0;
  z-index: 900;
  display: grid;
  place-items: center;
  background: var(--background);
}
.loading-screen .brand-mark { animation: breathe 1.2s ease-in-out infinite; }

.login-view {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 32px 20px;
}

.login-card {
  position: relative;
  width: min(100%, 430px);
  padding: 40px;
  border: 1px solid var(--line-translucent);
  border-radius: var(--radius-lg);
  background: var(--login-surface);
  box-shadow: var(--shadow-card);
  transition: border-color 180ms ease, background-color 180ms ease, box-shadow 180ms ease;
}

.login-theme-toggle { position: absolute; top: 26px; right: 26px; }
.theme-toggle { color: var(--ink-soft); }
.theme-toggle:hover { color: var(--ink); }
.theme-icon-sun { display: none; }
:root[data-theme="dark"] .theme-icon-moon { display: none; }
:root[data-theme="dark"] .theme-icon-sun { display: block; }

.brand-login { margin-bottom: 58px; }
.login-copy { margin-bottom: 32px; }
.login-copy h1, .intro h1 {
  margin: 0;
  font-size: clamp(30px, 6vw, 40px);
  line-height: 1.18;
  letter-spacing: -0.045em;
}
.login-copy > p:last-child, .intro > p:last-child {
  margin: 14px 0 0;
  color: var(--ink-soft);
}

form label {
  display: inline-block;
  margin-bottom: 8px;
  font-size: 14px;
  font-weight: 650;
}

.password-field { position: relative; }
.password-field input {
  width: 100%;
  min-height: 52px;
  padding: 12px 54px 12px 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  color: var(--ink);
  background: var(--field);
  transition: border-color 180ms ease, box-shadow 180ms ease;
}
.password-field input:focus {
  border-color: var(--accent);
  outline: 0;
  box-shadow: 0 0 0 3px var(--focus-shadow);
}

.icon-button {
  display: inline-grid;
  width: 44px;
  height: 44px;
  padding: 0;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
  transition: background-color 160ms ease, color 160ms ease;
}
.icon-button:hover { background: var(--surface-muted); }
.field-button { position: absolute; top: 4px; right: 4px; color: var(--ink-soft); }
.eye-closed { display: none; }
.field-button[aria-pressed="true"] .eye-open { display: none; }
.field-button[aria-pressed="true"] .eye-closed { display: block; }

.field-error {
  min-height: 24px;
  margin: 6px 0 8px;
  color: var(--danger);
  font-size: 14px;
}

.button {
  display: inline-flex;
  min-height: 46px;
  padding: 10px 16px;
  align-items: center;
  justify-content: center;
  gap: 9px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-weight: 650;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 160ms ease, border-color 160ms ease, transform 100ms ease, opacity 160ms ease;
}
.button:active { transform: scale(0.98); }
.button:disabled { cursor: not-allowed; opacity: 0.55; }
.button-primary { color: var(--on-accent); background: var(--accent); }
.button-primary:hover:not(:disabled) { background: var(--accent-hover); }
.button-wide { width: 100%; }
.button-light { color: #1c211d; background: white; border-color: rgb(255 255 255 / 30%); }
.button-light:hover { background: #f0f0ec; }

.privacy-note {
  display: flex;
  margin: 28px 0 0;
  align-items: center;
  justify-content: center;
  gap: 7px;
  color: var(--ink-faint);
  font-size: 13px;
}
.privacy-note .icon { width: 16px; height: 16px; }

.site-header {
  position: sticky;
  z-index: 20;
  top: 0;
  border-bottom: 1px solid var(--line-translucent);
  background: var(--header-surface);
  backdrop-filter: blur(16px);
  transition: border-color 180ms ease, background-color 180ms ease;
}
.header-inner {
  display: flex;
  width: min(calc(100% - 40px), 1120px);
  min-height: 72px;
  margin: auto;
  align-items: center;
  justify-content: space-between;
}
.header-actions { display: flex; align-items: center; gap: 10px; }
.private-badge {
  display: inline-flex;
  padding: 6px 10px;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  color: var(--accent);
  background: var(--accent-soft);
  font-size: 13px;
  font-weight: 650;
}
.private-badge .icon { width: 15px; height: 15px; }

.main-content {
  width: min(calc(100% - 40px), var(--content-width));
  margin: 0 auto;
  padding: 72px 0 max(96px, env(safe-area-inset-bottom));
}
.intro { margin-bottom: 34px; }

.composer {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-card);
  transition: border-color 180ms ease, background-color 180ms ease, box-shadow 180ms ease;
}
.composer:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--focus-shadow), var(--shadow-card);
}
.composer textarea {
  display: block;
  width: 100%;
  min-height: 138px;
  padding: 22px 22px 12px;
  resize: vertical;
  border: 0;
  outline: 0;
  color: var(--ink);
  background: transparent;
  font-size: 17px;
  line-height: 1.65;
}
.composer textarea::placeholder { color: var(--ink-faint); }
.composer-footer {
  display: flex;
  padding: 12px;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-top: 1px solid var(--line);
}
.composer-tools { display: flex; align-items: center; gap: 12px; min-width: 0; }
.tool-button {
  display: inline-flex;
  min-height: 44px;
  padding: 8px 10px;
  align-items: center;
  gap: 8px;
  border-radius: 9px;
  color: var(--ink-soft);
  font-size: 14px;
  font-weight: 650;
  cursor: pointer;
}
.tool-button:hover { color: var(--ink); background: var(--surface-muted); }
.paste-hint { color: var(--ink-faint); font-size: 13px; }

.file-previews {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 10px;
  padding: 0 20px 18px;
}
.file-previews:empty { display: none; }
.file-preview {
  position: relative;
  overflow: hidden;
  aspect-ratio: 1;
  border-radius: 12px;
  background: var(--surface-muted);
}
.file-preview img { width: 100%; height: 100%; object-fit: cover; }
.remove-preview {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 32px;
  height: 32px;
  color: white;
  background: rgb(20 23 20 / 72%);
  backdrop-filter: blur(8px);
}
.remove-preview:hover { background: rgb(20 23 20 / 88%); }
.remove-preview .icon { width: 16px; height: 16px; }

.drop-overlay {
  position: absolute;
  z-index: 10;
  inset: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 10px;
  border: 2px dashed var(--accent);
  border-radius: 17px;
  color: var(--accent);
  background: var(--drop-surface);
  font-weight: 680;
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease;
}
.drop-overlay .icon { width: 30px; height: 30px; }
.composer.is-dragging .drop-overlay { opacity: 1; }

.history { margin-top: 64px; }
.section-heading { display: flex; margin-bottom: 18px; align-items: baseline; justify-content: space-between; }
.section-heading h2 { margin: 0; font-size: 18px; letter-spacing: -0.02em; }
.item-count { color: var(--ink-faint); font-size: 13px; }
.items { display: grid; gap: 14px; }

.item-card {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
  box-shadow: var(--shadow-card);
  transition: border-color 180ms ease, background-color 180ms ease, box-shadow 180ms ease;
  animation: item-in 220ms ease-out both;
}
.text-card { padding: 20px; }
.text-content {
  margin: 0 0 18px;
  overflow-wrap: anywhere;
  color: var(--ink);
  font-size: 16px;
  line-height: 1.72;
  white-space: pre-wrap;
}
.item-meta { display: flex; min-height: 44px; align-items: center; justify-content: space-between; gap: 12px; }
.meta-time { color: var(--ink-faint); font-size: 13px; }
.card-actions { display: flex; gap: 4px; align-items: center; }
.card-action {
  display: inline-flex;
  min-width: 44px;
  min-height: 44px;
  padding: 8px 10px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 0;
  border-radius: 9px;
  color: var(--ink-soft);
  background: transparent;
  font-size: 13px;
  font-weight: 650;
  text-decoration: none;
  cursor: pointer;
}
.card-action:hover { color: var(--ink); background: var(--surface-muted); }
.card-action.is-danger, .card-action.is-confirming { color: var(--danger); }
.card-action.is-confirming { background: var(--danger-soft); }
.card-action .icon { width: 18px; height: 18px; }

.image-card { padding: 8px; }
.image-button {
  display: block;
  width: 100%;
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: 11px;
  background: var(--surface-muted);
  cursor: zoom-in;
}
.image-button img {
  width: 100%;
  max-height: 560px;
  min-height: 220px;
  object-fit: contain;
}
.image-card .item-meta { padding: 8px 8px 2px 10px; }
.image-name {
  display: block;
  max-width: min(40vw, 360px);
  overflow: hidden;
  color: var(--ink-soft);
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.empty-state { padding: 48px 20px; text-align: center; }
.empty-icon {
  display: grid;
  width: 48px;
  height: 48px;
  margin: 0 auto 16px;
  place-items: center;
  border-radius: 50%;
  color: var(--accent);
  background: var(--accent-soft);
}
.empty-state h3 { margin: 0; font-size: 17px; }
.empty-state p { margin: 5px 0 0; color: var(--ink-soft); font-size: 14px; }

.skeleton-card {
  height: 150px;
  border-radius: var(--radius-md);
  background: linear-gradient(100deg, var(--skeleton-base) 35%, var(--skeleton-shine) 50%, var(--skeleton-base) 65%);
  background-size: 300% 100%;
  animation: shimmer 1.5s ease infinite;
}
.skeleton-short { height: 110px; }

.toast {
  position: fixed;
  z-index: 1000;
  left: 50%;
  bottom: max(24px, env(safe-area-inset-bottom));
  max-width: calc(100% - 32px);
  padding: 11px 16px;
  border-radius: 10px;
  color: var(--background);
  background: var(--toast-surface);
  box-shadow: 0 8px 30px rgb(0 0 0 / 18%);
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 12px);
  transition: opacity 180ms ease, transform 180ms ease;
}
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }
.toast.is-error { background: var(--danger); }

.image-dialog {
  width: 100vw;
  max-width: none;
  height: 100dvh;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  color: white;
  background: #171a18;
}
.image-dialog::backdrop { background: rgb(0 0 0 / 70%); }
.image-dialog[open] { display: grid; grid-template-rows: auto 1fr auto; }
.dialog-bar, .dialog-actions {
  position: relative;
  z-index: 2;
  display: flex;
  padding: max(12px, env(safe-area-inset-top)) 18px 12px;
  align-items: center;
  gap: 12px;
}
.dialog-bar { justify-content: space-between; }
.dialog-bar p { margin: 0; overflow: hidden; color: #d4d7d4; font-size: 14px; text-overflow: ellipsis; white-space: nowrap; }
.icon-button-light { color: white; background: rgb(255 255 255 / 10%); }
.icon-button-light:hover { background: rgb(255 255 255 / 18%); }
.dialog-image-wrap { display: grid; min-height: 0; padding: 8px 18px; place-items: center; }
.dialog-image-wrap img { width: 100%; height: 100%; object-fit: contain; }
.dialog-actions { padding: 12px 18px max(18px, env(safe-area-inset-bottom)); justify-content: center; }

@keyframes breathe { 50% { transform: scale(1.18); opacity: 0.7; } }
@keyframes item-in { from { opacity: 0; transform: translateY(8px); } }
@keyframes shimmer { to { background-position-x: -300%; } }

@media (max-width: 620px) {
  .login-view { align-items: stretch; padding: 0; }
  .login-card {
    display: flex;
    min-height: 100dvh;
    padding: 28px 22px max(28px, env(safe-area-inset-bottom));
    flex-direction: column;
    justify-content: center;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
  }
  .brand-login { position: absolute; top: max(22px, env(safe-area-inset-top)); margin: 0; }
  .login-theme-toggle { top: max(18px, env(safe-area-inset-top)); right: 18px; }
  .header-inner, .main-content { width: min(calc(100% - 28px), var(--content-width)); }
  .header-inner { min-height: 64px; }
  .private-badge { width: 36px; height: 36px; padding: 0; justify-content: center; }
  .private-badge .icon { width: 17px; height: 17px; }
  .private-badge { font-size: 0; }
  .main-content { padding-top: 48px; }
  .intro { margin-bottom: 26px; }
  .composer textarea { min-height: 128px; padding: 18px 17px 10px; }
  .composer-footer { padding: 9px; }
  .paste-hint { display: none; }
  .tool-button { padding: 8px; font-size: 13px; }
  .file-previews { grid-template-columns: repeat(3, 1fr); padding: 0 15px 15px; }
  .history { margin-top: 48px; }
  .text-card { padding: 17px; }
  .text-content { margin-bottom: 12px; }
  .meta-time { font-size: 12px; }
  .card-action span { display: none; }
  .card-action.is-confirming span { display: inline; }
  .card-action.is-confirming { padding-inline: 12px; }
  .image-name { max-width: 44vw; }
  .image-button img { min-height: 180px; max-height: 72vh; }
  .dialog-actions .button { flex: 1; }
}

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