/* ===== Palm City｜Sunset Miami theme ===== */
:root {
  --bg: #120a24;
  --bg-2: #1c0f38;
  --panel: rgba(30, 17, 58, 0.78);
  --panel-solid: #1e113a;
  --field: rgba(10, 6, 24, 0.55);
  --border: rgba(255, 255, 255, 0.09);
  --border-strong: rgba(255, 255, 255, 0.18);
  --text: #f4ecff;
  --muted: #b7a8d8;
  --faint: #8a7bab;

  --pink: #ff4f8b;
  --coral: #ff7a7a;
  --orange: #ffa45c;
  --sun: #ffd166;
  --teal: #2ed3c6;
  --aqua: #5ee7df;
  --purple: #9b5de5;

  --sunset: linear-gradient(135deg, var(--pink) 0%, var(--coral) 45%, var(--orange) 100%);
  --ocean: linear-gradient(135deg, var(--teal) 0%, var(--aqua) 100%);
  --accent: var(--pink);

  --radius: 14px;
  --font: "Noto Sans TC", "Segoe UI", "Microsoft JhengHei", sans-serif;
  --script: "Pacifico", "Segoe Script", cursive;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { color-scheme: dark; }
body {
  min-height: 100vh;
  font-family: var(--font);
  color: var(--text);
  background-color: var(--bg);
  background-image:
    radial-gradient(ellipse 70% 45% at 50% -5%, rgba(255, 122, 122, 0.35), transparent 70%),
    radial-gradient(ellipse 50% 35% at 85% 10%, rgba(155, 93, 229, 0.25), transparent 70%),
    radial-gradient(ellipse 60% 40% at 10% 100%, rgba(46, 211, 198, 0.18), transparent 70%),
    linear-gradient(180deg, var(--bg-2) 0%, var(--bg) 60%);
  background-attachment: fixed;
  line-height: 1.6;
  overflow-x: hidden;
}
/* synthwave floor grid */
body::before {
  content: "";
  position: fixed; inset: auto 0 0 0; height: 38vh;
  background-image:
    linear-gradient(rgba(255, 79, 139, 0.22) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 79, 139, 0.22) 1px, transparent 1px);
  background-size: 48px 48px;
  transform: perspective(420px) rotateX(62deg);
  transform-origin: bottom;
  mask-image: linear-gradient(to top, rgba(0,0,0,.9), transparent 85%);
  -webkit-mask-image: linear-gradient(to top, rgba(0,0,0,.9), transparent 85%);
  pointer-events: none; z-index: -1;
}

a { color: var(--aqua); }
::selection { background: rgba(255, 79, 139, 0.45); }

/* ===== Top bar ===== */
.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px clamp(16px, 4vw, 40px);
  background: rgba(18, 10, 36, 0.72);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); }
.brand img { width: 40px; height: 40px; border-radius: 50%; box-shadow: 0 0 0 2px rgba(46,211,198,.5), 0 0 18px rgba(255,79,139,.45); }
.brand .wordmark { font-family: var(--script); font-size: 1.35rem; background: var(--sunset); -webkit-background-clip: text; background-clip: text; color: transparent; line-height: 1; padding: 4px 2px; }
.brand .sub { font-size: .72rem; letter-spacing: .18em; color: var(--aqua); font-weight: 700; }
.back {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px; border-radius: 999px;
  border: 1px solid var(--border-strong); color: var(--text); text-decoration: none; font-size: .9rem;
  transition: background .2s, border-color .2s;
}
.back:hover { background: rgba(255,255,255,.06); border-color: var(--aqua); }

/* ===== Home ===== */
.hero { text-align: center; padding: clamp(36px, 8vh, 72px) 16px 28px; }
.hero-logo {
  width: clamp(150px, 30vw, 210px); aspect-ratio: 1; border-radius: 50%;
  box-shadow: 0 0 0 4px rgba(46,211,198,.35), 0 0 60px rgba(255,79,139,.45), 0 20px 60px rgba(0,0,0,.5);
  animation: float 6s ease-in-out infinite;
}
@keyframes float { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
.hero h1 { margin-top: 22px; font-size: clamp(1.7rem, 4.5vw, 2.5rem); font-weight: 900; letter-spacing: .04em; }
.hero h1 .script { font-family: var(--script); font-weight: 400; background: var(--sunset); -webkit-background-clip: text; background-clip: text; color: transparent; padding: 0 .1em; }
.hero p { color: var(--muted); margin-top: 6px; }

.cards {
  max-width: 980px; margin: 0 auto; padding: 8px 16px 64px;
  display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); gap: 18px;
}
.card {
  --c: var(--pink);
  position: relative; overflow: hidden;
  display: flex; align-items: center; gap: 18px;
  padding: 22px; border-radius: var(--radius);
  background: var(--panel); border: 1px solid var(--border);
  text-decoration: none; color: var(--text);
  transition: transform .2s, border-color .2s, box-shadow .2s;
}
.card::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 4px; background: var(--c); }
.card:hover { transform: translateY(-3px); border-color: var(--c); box-shadow: 0 12px 34px rgba(0,0,0,.35), 0 0 24px color-mix(in srgb, var(--c) 30%, transparent); }
.card .icon {
  flex: none; width: 56px; height: 56px; border-radius: 14px; display: grid; place-items: center; font-size: 1.7rem;
  background: color-mix(in srgb, var(--c) 18%, transparent); border: 1px solid color-mix(in srgb, var(--c) 45%, transparent);
}
.card h2 { font-size: 1.15rem; }
.card p { color: var(--muted); font-size: .9rem; }
.card .go { margin-left: auto; color: var(--c); font-size: 1.3rem; transition: transform .2s; }
.card:hover .go { transform: translateX(4px); }

.foot-note { text-align: center; color: var(--faint); font-size: .8rem; padding: 0 16px 40px; }

/* ===== Form pages ===== */
.layout {
  max-width: 1240px; margin: 0 auto; padding: 28px clamp(16px, 3vw, 32px) 64px;
  display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); gap: 24px; align-items: start;
}
@media (max-width: 900px) { .layout { grid-template-columns: 1fr; } }

.panel { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: clamp(18px, 3vw, 28px); backdrop-filter: blur(6px); }
.page-title { display: flex; align-items: center; gap: 14px; margin-bottom: 8px; }
.page-title .icon { width: 48px; height: 48px; border-radius: 12px; display: grid; place-items: center; font-size: 1.5rem; background: color-mix(in srgb, var(--accent) 20%, transparent); border: 1px solid color-mix(in srgb, var(--accent) 50%, transparent); }
.page-title h1 { font-size: 1.55rem; font-weight: 900; }
.page-title small { display: block; color: var(--muted); font-weight: 400; font-size: .85rem; }
.divider { height: 2px; border: 0; margin: 16px 0 6px; background: linear-gradient(90deg, var(--accent), transparent); opacity: .7; }

.field { margin-top: 18px; }
.field > label, .label { display: flex; align-items: baseline; gap: 8px; font-weight: 700; font-size: .92rem; color: var(--muted); margin-bottom: 8px; }
.label .opt, .field > label .opt { font-weight: 400; color: var(--faint); font-size: .8rem; }
.hint { color: var(--faint); font-size: .8rem; margin-top: 6px; }
.hint.warn { color: var(--orange); }

input[type="text"], textarea, select {
  width: 100%; padding: 11px 13px; border-radius: 10px;
  background: var(--field); color: var(--text);
  border: 1px solid var(--border-strong); font: inherit; font-size: .95rem;
  transition: border-color .2s, box-shadow .2s;
}
input[type="text"]:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent); }
textarea { min-height: 120px; resize: vertical; line-height: 1.55; }
textarea.short { min-height: 70px; }
::placeholder { color: #6f6290; }
select option { background: var(--panel-solid); }

/* markdown editor */
.editor { border: 1px solid var(--border-strong); border-radius: 10px; overflow: hidden; background: var(--field); }
.editor:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent); }
.editor textarea { border: 0; border-radius: 0; background: transparent; box-shadow: none !important; min-height: 180px; font-family: "Cascadia Mono", Consolas, var(--font); font-size: .9rem; }
.toolbar { display: flex; flex-wrap: wrap; gap: 2px; padding: 6px; border-bottom: 1px solid var(--border); background: rgba(255,255,255,.03); }
.toolbar button { min-width: 32px; height: 30px; padding: 0 8px; border: 0; border-radius: 6px; background: transparent; color: var(--muted); font: inherit; font-size: .85rem; cursor: pointer; }
.toolbar button:hover { background: rgba(255,255,255,.08); color: var(--text); }
.toolbar .sep { width: 1px; margin: 4px 4px; background: var(--border-strong); }
.counter { text-align: right; font-size: .75rem; color: var(--faint); margin-top: 4px; }
.counter.over { color: var(--pink); font-weight: 700; }

/* file input */
.file {
  display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: 10px;
  border: 1px dashed var(--border-strong); background: var(--field); cursor: pointer;
}
.file:hover { border-color: var(--aqua); }
.file input { display: none; }
.file .btn-mini { padding: 6px 12px; border-radius: 8px; background: rgba(46,211,198,.15); color: var(--aqua); font-weight: 700; font-size: .85rem; white-space: nowrap; }
.file .name { color: var(--muted); font-size: .88rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* toggle / checkbox */
.check { display: flex; align-items: center; gap: 10px; margin-top: 18px; cursor: pointer; user-select: none; color: var(--text); }
.check input { appearance: none; -webkit-appearance: none; width: 42px; height: 24px; border-radius: 999px; background: rgba(255,255,255,.14); position: relative; cursor: pointer; transition: background .2s; flex: none; }
.check input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform .2s; }
.check input:checked { background: var(--teal); }
.check input:checked::after { transform: translateX(18px); }
.check input:disabled { opacity: .4; cursor: not-allowed; }
.role-pill { color: #c9cdfb; background: rgba(88,101,242,.3); padding: 1px 6px; border-radius: 4px; font-weight: 600; }

/* segmented */
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 5px; border-radius: 12px; background: var(--field); border: 1px solid var(--border-strong); }
.seg input { display: none; }
.seg label { text-align: center; padding: 9px; border-radius: 8px; cursor: pointer; font-weight: 700; color: var(--muted); transition: background .2s, color .2s; }
.seg input:checked + label { color: #1a0d2e; }
.seg input[value="fail"]:checked + label { background: var(--sunset); }
.seg input[value="pass"]:checked + label { background: var(--ocean); }

/* repeating blocks */
.block { position: relative; margin-top: 16px; padding: 16px; border-radius: 12px; border: 1px solid var(--border); background: rgba(255,255,255,.025); }
.block-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 4px; }
.block-head .num { font-weight: 900; font-size: .85rem; color: var(--accent); letter-spacing: .08em; }
.icon-btn { border: 0; background: rgba(255,79,139,.14); color: var(--pink); width: 30px; height: 30px; border-radius: 8px; cursor: pointer; font-size: .95rem; }
.icon-btn:hover { background: rgba(255,79,139,.3); }
.row { display: grid; grid-template-columns: 160px 1fr; gap: 10px; }
@media (max-width: 520px) { .row { grid-template-columns: 1fr; } }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 0; border-radius: 10px; padding: 12px 18px; font: inherit; font-weight: 800; cursor: pointer; transition: transform .15s, filter .2s, opacity .2s; }
.btn:active { transform: scale(.98); }
.btn-ghost { width: 100%; margin-top: 14px; background: transparent; color: var(--aqua); border: 1px dashed rgba(94,231,223,.5); }
.btn-ghost:hover { background: rgba(94,231,223,.08); }
.btn-send { width: 100%; margin-top: 26px; padding: 14px; color: #1a0d2e; font-size: 1.02rem; background: var(--sunset); box-shadow: 0 8px 26px rgba(255,79,139,.35); }
.btn-send:hover { filter: brightness(1.08); }
.btn-send.danger { background: linear-gradient(135deg, #ff3d5a, #ff7a59); color: #fff; }
.btn-send:disabled { opacity: .6; cursor: progress; }

/* ===== Discord preview ===== */
.preview-panel { position: sticky; top: 84px; padding: 0; overflow: hidden; }
@media (max-width: 900px) { .preview-panel { position: static; } }
.preview-head { display: flex; align-items: center; gap: 8px; padding: 12px 16px; font-weight: 800; font-size: .9rem; color: var(--muted); border-bottom: 1px solid var(--border); background: rgba(255,255,255,.03); }
.preview-head .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--teal); box-shadow: 0 0 10px var(--teal); }
.dc { background: #313338; color: #dbdee1; font-family: "gg sans", "Noto Sans TC", "Segoe UI", sans-serif; font-size: .94rem; line-height: 1.375; padding: 16px 16px 20px; max-height: calc(100vh - 160px); overflow: auto; }
@media (max-width: 900px) { .dc { max-height: none; } }
.dc-empty { color: #80848e; text-align: center; padding: 40px 10px; font-size: .9rem; }
.dc-msg { display: flex; gap: 14px; }
.dc-msg + .dc-msg { margin-top: 18px; }
.dc-avatar { width: 40px; height: 40px; border-radius: 50%; flex: none; object-fit: cover; }
.dc-main { min-width: 0; flex: 1; }
.dc-head { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.dc-name { color: #f2f3f5; font-weight: 600; }
.dc-app { background: #5865f2; color: #fff; font-size: .62rem; font-weight: 700; padding: 1px 5px; border-radius: 4px; }
.dc-time { color: #949ba4; font-size: .75rem; }
.dc-content { margin-top: 2px; overflow-wrap: anywhere; }
.dc-embed { margin-top: 6px; max-width: 520px; display: grid; gap: 8px; padding: 10px 16px 14px 12px; border-radius: 4px; background: #2b2d31; border-left: 4px solid var(--ec, #1e1f22); }
.dc-embed-author { font-size: .82rem; font-weight: 600; color: #f2f3f5; }
.dc-embed-title { font-weight: 700; color: #f2f3f5; font-size: 1rem; }
.dc-embed-desc { font-size: .88rem; overflow-wrap: anywhere; }
.dc-fields { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.dc-field { grid-column: 1 / -1; font-size: .88rem; }
.dc-field.inline { grid-column: auto; }
.dc-field-name { font-weight: 700; color: #f2f3f5; margin-bottom: 2px; }
.dc-footer { font-size: .75rem; color: #b5bac1; display: flex; align-items: center; gap: 6px; }
.dc-footer img { width: 18px; height: 18px; border-radius: 50%; }
.dc-thumb { float: right; width: 72px; height: 72px; border-radius: 4px; object-fit: cover; margin-left: 12px; }
.dc-attach { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.dc-attach img { max-width: 220px; max-height: 160px; border-radius: 6px; object-fit: cover; }

/* discord markdown */
.md h1 { font-size: 1.45em; color: #f2f3f5; margin: 8px 0 4px; line-height: 1.25; }
.md h2 { font-size: 1.22em; color: #f2f3f5; margin: 8px 0 4px; }
.md h3 { font-size: 1.05em; color: #f2f3f5; margin: 8px 0 4px; }
.md .sub { font-size: .78em; color: #949ba4; }
.md blockquote { border-left: 4px solid #4e5058; padding-left: 10px; margin: 2px 0; }
.md pre { background: #1e1f22; border: 1px solid #1a1b1e; border-radius: 4px; padding: 7px 9px; margin: 4px 0; white-space: pre-wrap; font-family: Consolas, "Cascadia Mono", monospace; font-size: .85em; }
.md code { background: #1e1f22; padding: 1px 4px; border-radius: 3px; font-family: Consolas, monospace; font-size: .85em; }
.md .li { padding-left: 18px; position: relative; }
.md .li::before { content: "•"; position: absolute; left: 4px; }
.md .li.ol::before { content: attr(data-n) "."; left: 0; }
.md .gap { height: .6em; }
.md a { color: #00a8fc; text-decoration: none; }
.mention { background: rgba(88,101,242,.3); color: #c9cdfb; padding: 0 2px; border-radius: 3px; font-weight: 500; }

/* ===== Toast ===== */
.toasts { position: fixed; top: 76px; left: 50%; transform: translateX(-50%); z-index: 999; display: grid; gap: 8px; width: min(92vw, 420px); }
.toast { padding: 12px 16px; border-radius: 12px; font-weight: 700; color: #fff; display: flex; gap: 10px; align-items: flex-start; box-shadow: 0 10px 30px rgba(0,0,0,.45); animation: toastIn .25s ease-out; }
.toast.ok { background: linear-gradient(135deg, #14b8a6, #22c55e); }
.toast.err { background: linear-gradient(135deg, #ff3d5a, #ff7a59); }
.toast.warn { background: linear-gradient(135deg, #f59e0b, #ffa45c); color: #1a0d2e; }
.toast span { flex: 1; font-weight: 600; }
.toast button { background: none; border: 0; color: inherit; cursor: pointer; font-size: 1rem; }
@keyframes toastIn { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: none; } }

.config-warn { max-width: 980px; margin: 0 auto 18px; padding: 12px 16px; border-radius: 12px; background: rgba(255,164,92,.12); border: 1px solid rgba(255,164,92,.45); color: var(--sun); font-size: .9rem; }
.config-warn code { color: #fff; }

/* 單一功能時置中 */
.cards.single { grid-template-columns: minmax(0, 520px); justify-content: center; }

/* 功能關閉畫面 */
.panel.closed { grid-column: 1 / -1; max-width: 560px; margin: 40px auto; text-align: center; display: grid; gap: 12px; justify-items: center; }
.panel.closed .icon { font-size: 2.6rem; }
.panel.closed p { color: var(--muted); }
.panel.closed code { color: var(--aqua); }

/* diff 程式碼框上色（模擬 Discord） */
.md pre .d-add { color: #7fd99a; }
.md pre .d-del { color: #f38b8b; }
.toolbar .tb-add { color: #7fd99a; }
.toolbar .tb-del { color: #f38b8b; }

/* 已加入的圖片縮圖 */
.thumbs { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.thumbs:empty { display: none; }
.thumb { position: relative; width: 84px; height: 84px; border-radius: 10px; overflow: hidden; border: 1px solid var(--border-strong); background: var(--field); }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb button { position: absolute; top: 4px; right: 4px; width: 22px; height: 22px; border: 0; border-radius: 50%; background: rgba(0,0,0,.65); color: #fff; font-size: .75rem; cursor: pointer; }
.thumb button:hover { background: var(--pink); }
