:root {
  color-scheme: light;
  --bg: #f5f6f8;
  --card: #ffffff;
  --text: #171a21;
  --muted: #9298a3;
  --line: #e8eaf0;
  --accent: #5668e9;
  --accent-soft: #eef0ff;
  --radius: 22px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(circle at 50% 0, rgba(86, 104, 233, .12), transparent 28rem),
    var(--bg);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}

button, input, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

.app {
  width: min(100% - 32px, 760px);
  margin: 0 auto;
  padding: clamp(40px, 9vh, 90px) 0 32px;
}

header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 11px;
  margin-bottom: 28px;
}

.mark {
  width: 14px;
  height: 14px;
  border: 4px solid var(--accent);
  border-radius: 5px;
  transform: rotate(45deg);
}

h1 {
  margin: 0;
  font-size: 30px;
  font-weight: 760;
  letter-spacing: .08em;
}

.main-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px;
  margin-bottom: 14px;
  padding: 5px;
  border-radius: 17px;
  background: #e9ebf0;
}

.main-tab {
  height: 54px;
  border: 0;
  border-radius: 13px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  font-size: 18px;
  font-weight: 750;
}

.main-tab.active {
  color: var(--text);
  background: var(--card);
  box-shadow: 0 3px 12px rgba(30, 38, 60, .07);
}

.panel, .result {
  padding: 26px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: 0 16px 46px rgba(31, 40, 65, .06);
}

.type-tabs {
  display: flex;
  gap: 7px;
  margin-bottom: 16px;
}

.type-tab {
  padding: 9px 16px;
  border: 0;
  border-radius: 10px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  font-size: 14px;
  font-weight: 650;
}

.type-tab.active { color: var(--accent); background: var(--accent-soft); }

.drop-zone {
  display: flex;
  min-height: 210px;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 12px;
  padding: 24px;
  border: 1.5px dashed #ccd1dc;
  border-radius: 17px;
  color: var(--muted);
  background: #fafbfc;
  cursor: pointer;
  text-align: center;
  transition: .16s ease;
}

.drop-zone:hover, .drop-zone.dragging {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
}

.drop-zone input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.drop-zone svg { width: 27px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.drop-zone span {
  max-width: 100%;
  font-size: 15px;
  font-weight: 650;
  line-height: 1.55;
  overflow-wrap: anywhere;
  white-space: normal;
}

textarea, .id-input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 15px;
  outline: 0;
  color: var(--text);
  background: #fafbfc;
  transition: border .16s, box-shadow .16s;
}

textarea {
  min-height: 150px;
  max-height: 480px;
  padding: 16px;
  resize: none;
  overflow-y: hidden;
  font-size: 16px;
  line-height: 1.65;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.id-input {
  min-height: 58px;
  max-height: 118px;
  padding: 15px 16px;
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 14px;
  line-height: 1.55;
}

textarea:focus, .id-input:focus {
  border-color: rgba(86, 104, 233, .65);
  box-shadow: 0 0 0 4px rgba(86, 104, 233, .09);
}

textarea::placeholder, .id-input::placeholder { color: #acb1bb; }

.action {
  width: 100%;
  height: 54px;
  margin-top: 14px;
  border: 0;
  border-radius: 15px;
  color: #fff;
  background: var(--accent);
  cursor: pointer;
  font-size: 18px;
  font-weight: 750;
  transition: transform .16s, opacity .16s, background .16s;
}

.action:hover:not(:disabled) { background: #4659d5; transform: translateY(-1px); }
.action:disabled { cursor: not-allowed; opacity: .38; }

.result { margin-top: 16px; padding: 21px; }
.result-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin-bottom: 14px; }
.file-name {
  min-width: 0;
  font-size: 16px;
  font-weight: 700;
  line-height: 1.5;
  overflow-wrap: anywhere;
  white-space: normal;
}
.file-size { flex: 0 0 auto; padding-top: 3px; color: #707887; font-size: 13px; font-weight: 600; }
.id-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) repeat(3, 40px);
  align-items: center;
  gap: 8px;
  padding: 13px;
  border-radius: 14px;
  background: #f4f5f8;
}
.id-row code {
  display: block;
  min-width: 0;
  overflow-wrap: anywhere;
  white-space: normal;
  color: #3f4755;
  font-size: 13px;
  line-height: 1.6;
}

.icon-button {
  display: grid;
  width: 40px;
  height: 40px;
  flex: 0 0 auto;
  place-items: center;
  border: 0;
  border-radius: 10px;
  color: #697181;
  background: #fff;
  cursor: pointer;
}

.icon-button:hover { color: var(--accent); }
.delete-button:hover { color: #cc4b4b; }
.icon-button svg { width: 19px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.preview {
  margin-top: 12px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #f8f9fb;
}

.preview img {
  display: block;
  width: 100%;
  max-height: 520px;
  object-fit: contain;
  background: #eef0f3;
}

.preview pre {
  max-height: 420px;
  margin: 0;
  padding: 15px;
  overflow: auto;
  color: #414855;
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 15px;
  line-height: 1.75;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

dialog {
  width: min(100% - 36px, 340px);
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 19px;
  background: #fff;
  box-shadow: 0 24px 70px rgba(20, 26, 40, .22);
}

dialog::backdrop { background: rgba(20, 24, 32, .36); backdrop-filter: blur(3px); }
dialog input {
  width: 100%;
  height: 50px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 13px;
  outline: 0;
  background: #f8f9fb;
  font-size: 16px;
}
dialog input:focus { border-color: rgba(86, 104, 233, .65); box-shadow: 0 0 0 4px rgba(86, 104, 233, .09); }
.dialog-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin-top: 13px; }
.dialog-actions button { height: 47px; border: 0; border-radius: 12px; background: #eef0f4; cursor: pointer; font-size: 15px; font-weight: 700; }
.dialog-actions .confirm-delete { color: #fff; background: #cb4b4b; }

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  padding: 11px 16px;
  border-radius: 12px;
  color: #fff;
  background: #20242d;
  box-shadow: 0 10px 30px rgba(20, 25, 36, .2);
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: .18s ease;
}

.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { background: #c94c4c; }

@media (max-width: 520px) {
  .app { width: min(100% - 20px, 760px); padding-top: 30px; }
  .panel { padding: 19px; }
  .drop-zone { min-height: 180px; }
  textarea:not(.id-input) { min-height: 130px; max-height: 380px; }
  .result { padding: 17px; }
  .result-head { gap: 8px; }
  .id-row { grid-template-columns: repeat(3, 1fr); }
  .id-row code { grid-column: 1 / -1; margin-bottom: 4px; font-size: 12px; }
  .icon-button { width: 100%; }
}

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