:root {
	--bg: #1b1b1b;
	--panel: #232323;
	--panel2: #2b2b2b;
	--border: #3a3a3a;
	--text: #ebeae7;
	--muted: #9b9a96;
	--gold: #cfa524;
	--gold2: #edde5d;
	--danger: #b8453f;
	--red: #e05d56;
	--green: #6fce97;
	--accent-soft: #2e2712;
	--shadow: rgba(0, 0, 0, .75);
}

/* light theme — follows the forum's style, or the toggle in the header */
:root.light {
	--bg: #ebeae7;
	--panel: #ffffff;
	--panel2: #f5f4f1;
	--border: #d7d5d0;
	--text: #1b1b1b;
	--muted: #6b6a66;
	--gold: #a67c0a;
	--gold2: #7c5c05;
	--danger: #b8453f;
	--red: #c0433d;
	--green: #2c8a55;
	--accent-soft: #faf3dc;
	--shadow: rgba(27, 27, 27, .22);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html {
	/* always reserve the scrollbar so content never jumps sideways once the page grows */
	scrollbar-gutter: stable;
	overflow-y: scroll;
}
html, body { background: var(--bg); color: var(--text); font: 14px/1.5 "Segoe UI", system-ui, sans-serif; min-height: 100%; }
a { color: var(--gold2); text-decoration: none; }
button, input, select { font-family: inherit; }

/* ---------------- top bar ---------------- */
.topbar {
	display: flex; align-items: center; gap: 14px;
	padding: 0 22px; height: 60px;
	background: var(--panel);
	border-bottom: 1px solid var(--border);
	box-shadow: 0 1px 0 rgba(212, 169, 68, .16);
	position: sticky; top: 0; z-index: 30;
}
.topbar .brand { display: flex; align-items: center; }
.topbar .brand img { height: 34px; width: auto; display: block; }
.brand-text {
	display: flex; flex-direction: column; justify-content: center; gap: 1px;
	padding-left: 14px; margin-left: 2px; border-left: 1px solid var(--border); flex: 1;
	min-width: 0;
}
.brand-text h1 { font-size: 15.5px; font-weight: 700; letter-spacing: .2px; color: var(--text); }
.brand-text small { font-size: 11px; color: var(--muted); letter-spacing: .3px; }
.toplinks { display: flex; align-items: center; }
.toplinks a { margin-left: 14px; font-weight: 600; color: var(--muted); white-space: nowrap; }
.toplinks a:hover { color: var(--gold2); }
#themeToggle, #langToggle {
	margin-left: 10px; height: 34px; border-radius: 9px; cursor: pointer;
	border: 1px solid var(--border); background: var(--panel2); font-size: 15px; line-height: 1;
	color: var(--text);
}
#themeToggle { width: 34px; }
#langToggle { padding: 0 11px; font-size: 12px; font-weight: 800; letter-spacing: .5px; }
#themeToggle:hover, #langToggle:hover { border-color: var(--gold); color: var(--gold2); }
.t-light { display: none; }
:root.light .t-light { display: inline; }
:root.light .t-dark { display: none; }

/* ---------------- layout ---------------- */
.layout {
	display: grid; grid-template-columns: 320px minmax(0, 1fr); gap: 16px;
	max-width: 1180px; margin: 18px auto; padding: 0 18px;
	align-items: start;
}
.right { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.panel {
	background: var(--panel); border: 1px solid var(--border); border-radius: 12px;
	padding: 16px;
}
.panel h2 {
	font-size: 12px; text-transform: uppercase; letter-spacing: .9px;
	color: var(--gold); margin-bottom: 14px; font-weight: 800;
}
.panel h2 small {
	display: block; text-transform: none; letter-spacing: .2px; font-weight: 500;
	font-size: 11.5px; color: var(--muted); margin-top: 3px;
}

/* ---------------- setup form ---------------- */
.fld { display: block; margin-bottom: 12px; }
.fld > span {
	display: block; font-size: 11px; font-weight: 700; letter-spacing: .4px;
	text-transform: uppercase; color: var(--muted); margin-bottom: 5px;
}
.fld input, .fld select {
	width: 100%; height: 38px; padding: 0 10px;
	background: var(--panel2); color: var(--text);
	border: 1px solid var(--border); border-radius: 8px; font-size: 13.5px;
}
.fld input:focus, .fld select:focus { outline: none; border-color: var(--gold); }
/* the native calendar/clock glyph is nearly invisible on a dark field */
:root:not(.light) .fld input[type="datetime-local"]::-webkit-calendar-picker-indicator {
	filter: invert(1) opacity(.65); cursor: pointer;
}

.quick { margin: 14px 0 4px; }
.qlbl {
	display: block; font-size: 11px; font-weight: 700; letter-spacing: .4px;
	text-transform: uppercase; color: var(--muted); margin-bottom: 6px;
}
.qbtns { display: flex; flex-wrap: wrap; gap: 7px; }
.qbtns button {
	padding: 8px 13px; font-size: 12.5px; font-weight: 700; cursor: pointer;
	background: var(--panel2); color: var(--text);
	border: 1px solid var(--border); border-radius: 999px;
	transition: border-color .15s, color .15s, background .15s;
}
.qbtns button:hover { border-color: var(--gold); color: var(--gold2); background: var(--accent-soft); }

.actions { display: grid; grid-template-columns: 1fr auto; gap: 8px; margin-top: 16px; }
.actions button {
	padding: 12px 14px; border-radius: 10px; cursor: pointer; font-weight: 800; font-size: 13px;
	border: 1px solid var(--gold); background: var(--accent-soft); color: var(--gold2);
	transition: background .15s, color .15s, border-color .15s;
}
.actions button:hover { background: var(--gold); color: #17110b; }
.actions button:disabled { opacity: .6; cursor: progress; }
.actions button:disabled:hover { background: var(--accent-soft); color: var(--gold2); }
:root.light .actions button:hover { color: #fff; }
.actions button.danger { border-color: var(--border); background: var(--panel2); color: var(--muted); }
.actions button.danger:hover { border-color: var(--danger); color: var(--red); background: var(--panel2); }

.note { margin-top: 12px; font-size: 11.5px; line-height: 1.6; color: var(--muted); }

/* ---------------- the produced link ---------------- */
.shareout {
	margin-top: 14px; padding: 12px;
	background: var(--accent-soft); border: 1px solid var(--gold);
	border-radius: 10px;
}
.shareout[hidden] { display: none; }
.solbl {
	display: block; font-size: 10px; font-weight: 800; letter-spacing: .6px;
	text-transform: uppercase; color: var(--gold2); margin-bottom: 6px;
}
.srow { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px; }
#shareUrl {
	height: 34px; padding: 0 9px; min-width: 0;
	background: var(--panel); color: var(--text);
	border: 1px solid var(--border); border-radius: 7px;
	font: 12px/1.4 ui-monospace, Consolas, "Courier New", monospace;
}
#shareUrl:focus { outline: none; border-color: var(--gold); }
#shareCopy {
	padding: 0 12px; height: 34px; cursor: pointer; font-size: 11.5px; font-weight: 800;
	border: 1px solid var(--gold); border-radius: 7px;
	background: var(--panel); color: var(--gold2);
}
#shareCopy:hover { background: var(--gold); color: #17110b; }
:root.light #shareCopy:hover { color: #fff; }
#shareCopy.ok { border-color: var(--green); color: var(--green); background: var(--panel); }
#shareOpen {
	display: inline-block; margin-top: 8px; font-size: 11.5px; font-weight: 700;
}
.swarn { margin-top: 8px; font-size: 11px; line-height: 1.5; color: var(--muted); }
.swarn[hidden] { display: none; }

/* ---------------- countdown display ---------------- */
.display {
	text-align: center; padding: 28px 18px 22px;
	/* a thin gold cap marks this as the panel that matters */
	border-top: 3px solid var(--gold);
}
.ev-title {
	font-size: 22px; font-weight: 800; letter-spacing: .3px; color: var(--gold2);
	margin-bottom: 20px; word-break: break-word;
}
.clock { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.unit {
	background: var(--panel2); border: 1px solid var(--border); border-radius: 12px;
	padding: 18px 4px 13px;
}
.unit b {
	display: block; font-size: 44px; line-height: 1; font-weight: 800;
	color: var(--text); font-variant-numeric: tabular-nums;
	/* the widest digits reserve the space, so ticking never nudges the layout */
	font-feature-settings: "tnum";
}
.unit span {
	display: block; margin-top: 7px; font-size: 10.5px; font-weight: 700;
	letter-spacing: .8px; text-transform: uppercase; color: var(--muted);
}
.clock.done .unit b { color: var(--muted); }
.clock.live .unit b { color: var(--gold2); }

.state {
	margin-top: 14px; font-size: 13px; font-weight: 700; min-height: 20px;
}
.state.upcoming { color: var(--muted); }
.state.passed { color: var(--red); }
.state.now { color: var(--green); }
.state.invalid { color: var(--red); }

.whenline {
	margin-top: 16px; padding-top: 14px; border-top: 1px dashed var(--border);
	display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; text-align: left;
}
.whenline .kv { min-width: 0; }
.whenline .kv span {
	display: block; font-size: 10px; font-weight: 700; letter-spacing: .5px;
	text-transform: uppercase; color: var(--muted); margin-bottom: 3px;
}
.whenline .kv b {
	display: block; font-size: 12.5px; font-weight: 700; color: var(--text);
	word-break: break-word;
}

#btnOwn {
	display: none; margin: 16px auto 0; padding: 9px 18px;
	font-size: 12.5px; font-weight: 800; cursor: pointer;
	border: 1px solid var(--border); border-radius: 9px;
	background: var(--panel2); color: var(--muted);
}
#btnOwn:hover { border-color: var(--gold); color: var(--gold2); }

/* ---- arrived through a shared link: the countdown alone, no authoring tools ---- */
html.viewonly .setup,
html.viewonly .discord { display: none; }
html.viewonly .layout { grid-template-columns: minmax(0, 1fr); max-width: 780px; }
html.viewonly #btnOwn { display: block; }
html.viewonly .display { padding: 30px 16px 22px; }
html.viewonly .ev-title { font-size: 24px; margin-bottom: 20px; }
html.viewonly .unit b { font-size: 46px; }

/* ---------------- discord tags ---------------- */
.dset {
	display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px;
	padding-bottom: 14px; margin-bottom: 14px;
	border-bottom: 1px dashed var(--border);
}
.dset label { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.dset label:first-child { flex: 0 0 190px; }
.dtznote { flex: 1 1 auto; font-size: 11.5px; color: var(--muted); line-height: 34px; }
.dtznote b { color: var(--text); font-weight: 700; }
.dset label > span {
	font-size: 10px; font-weight: 700; letter-spacing: .5px;
	text-transform: uppercase; color: var(--muted);
}
.dset input, .dset select {
	height: 34px; padding: 0 9px; width: 100%;
	background: var(--panel2); color: var(--text);
	border: 1px solid var(--border); border-radius: 8px; font-size: 13px;
}
.dset input:focus, .dset select:focus { outline: none; border-color: var(--gold); }
:root:not(.light) .dset input[type="datetime-local"]::-webkit-calendar-picker-indicator {
	filter: invert(1) opacity(.65); cursor: pointer;
}
/* only offered once the timestamp has drifted away from the countdown */
#dsync {
	display: none; height: 34px; padding: 0 12px; cursor: pointer;
	font-size: 11.5px; font-weight: 800;
	border: 1px solid var(--gold); border-radius: 8px;
	background: var(--accent-soft); color: var(--gold2);
}
#dsync.on { display: block; }
#dsync:hover { background: var(--gold); color: #17110b; }
:root.light #dsync:hover { color: #fff; }

.dlist { display: flex; flex-direction: column; gap: 6px; }
.drow {
	display: grid; grid-template-columns: 104px minmax(0, 1fr) minmax(0, 148px) auto;
	align-items: center; gap: 12px;
	background: var(--panel2); border: 1px solid var(--border); border-radius: 9px;
	padding: 7px 10px;
}
.drow .dname {
	font-size: 11px; font-weight: 800; letter-spacing: .4px; text-transform: uppercase;
	color: var(--muted);
}
.drow .dprev {
	font-size: 13.5px; font-weight: 600; color: var(--text);
	background: rgba(88, 101, 242, .12);          /* Discord blurple, as a chat highlight */
	border-radius: 5px; padding: 3px 8px;
	/* a grid item stretches by default, which turned the highlight into a long
	   empty bar — this makes the tint hug the text like it does in Discord */
	justify-self: start; display: inline-block; max-width: 100%;
	white-space: normal; overflow-wrap: anywhere;
}
.drow .dcode {
	font: 12px/1.4 ui-monospace, Consolas, "Courier New", monospace;
	color: var(--gold2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.drow button {
	padding: 6px 12px; font-size: 11.5px; font-weight: 800; cursor: pointer;
	border: 1px solid var(--border); border-radius: 7px;
	background: var(--panel); color: var(--muted);
}
.drow button:hover { border-color: var(--gold); color: var(--gold2); }
.drow button.ok { border-color: var(--green); color: var(--green); }
/* the raw epoch row: no Discord rendering to preview, so show it plainly */
.drow.raw { border-style: dashed; }
.drow.raw .dprev {
	background: none; padding: 2px 0; color: var(--muted);
	font: 12.5px/1.4 ui-monospace, Consolas, "Courier New", monospace;
}

/* ---------------- footer + toast ---------------- */
.foot {
	text-align: center; padding: 18px; margin-top: 8px;
	font-size: 11.5px; color: var(--muted);
	border-top: 1px solid var(--border);
}

#toast {
	position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%) translateY(14px);
	background: var(--panel); border: 1px solid var(--gold); color: var(--text);
	padding: 10px 18px; border-radius: 9px; font-size: 13px; font-weight: 700;
	box-shadow: 0 12px 34px var(--shadow);
	opacity: 0; pointer-events: none; transition: opacity .18s, transform .18s; z-index: 99;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.err { border-color: var(--danger); color: var(--red); }

/* ---- embedded inside the forum: the forum supplies header/footer ---- */
html.embedded { overflow-y: auto; scrollbar-gutter: auto; background: var(--bg); }
html.embedded body { background: var(--bg); }
html.embedded .topbar,
html.embedded .foot { display: none; }
html.embedded .layout { margin-top: 0; padding-top: 0; }
/* `fixed` would pin the toast to the bottom of the (very tall) iframe, far
   out of view — inside the frame it is positioned near the pointer instead. */
html.embedded #toast {
	position: absolute; bottom: auto;
	transform: translate(-50%, calc(-100% + 14px));
}
html.embedded #toast.show { transform: translate(-50%, -100%); }

/* ---------------- responsive ---------------- */
@media (max-width: 900px) {
	.layout { grid-template-columns: 1fr; gap: 14px; margin: 14px auto; padding: 0 12px; }
	.topbar { padding: 0 12px; gap: 10px; }
	.brand-text h1 { font-size: 14px; }
	.brand-text small { display: none; }
	.toplinks a { margin-left: 10px; font-size: 12.5px; }
	.unit b { font-size: 30px; }
	.whenline { grid-template-columns: 1fr; gap: 8px; }

	/* the code column is the first thing to go — the copy button still delivers it */
	.drow { grid-template-columns: 84px minmax(0, 1fr) auto; }
	.drow .dcode { display: none; }
}
@media (max-width: 560px) {
	/* two rows of two beats four cramped columns */
	.clock { grid-template-columns: repeat(2, 1fr); }
	.unit b { font-size: 34px; }
	.toplinks a { display: none; }
	.ev-title { font-size: 17px; }
}

/* notice shown when this browser reopened its own saved setup */
.restored {
	margin-bottom: 12px; padding: 9px 11px; border-radius: 8px;
	background: var(--panel2); border: 1px solid var(--border);
	font-size: 11.5px; line-height: 1.5; color: var(--muted);
}
.restored[hidden] { display: none; }
.restored a { margin-left: 5px; font-weight: 700; white-space: nowrap; }


/* ============================================================
   Shared topbar navigation + footer
   The tool you are on is marked and not a link; on narrow screens the
   strip scrolls sideways instead of disappearing, which used to leave
   phones with no way between the tools at all.
   ============================================================ */
.toolnav {
	display: flex; align-items: center; gap: 4px;
	min-width: 0; overflow-x: auto; scrollbar-width: none;
}
.toolnav::-webkit-scrollbar { display: none; }
.toolnav .tn {
	padding: 6px 11px; border-radius: 8px; font-size: 12.5px; font-weight: 600;
	color: var(--muted); white-space: nowrap; border: 1px solid transparent;
	transition: color .15s, background .15s, border-color .15s;
}
.toolnav a.tn:hover { color: var(--gold2); background: var(--panel2); }
.toolnav .tn.is-here {
	color: var(--gold2); background: var(--accent-soft);
	border-color: var(--gold); cursor: default;
}
.forumlink {
	margin-left: 10px; padding: 6px 12px; border-radius: 8px;
	font-size: 12.5px; font-weight: 700; white-space: nowrap;
	color: var(--text); border: 1px solid var(--border); background: var(--panel2);
}
.forumlink:hover { border-color: var(--gold); color: var(--gold2); }

.foot { text-align: left; padding: 26px 22px 18px; }
.fcols {
	display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
	gap: 22px; max-width: 1180px; margin: 0 auto 18px;
}
.fcol { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.fcol h4 {
	font-size: 11px; text-transform: uppercase; letter-spacing: .7px;
	color: var(--gold); font-weight: 800; margin-bottom: 3px;
}
.fcol a { font-size: 12.5px; color: var(--muted); }
.fcol a:hover { color: var(--gold2); }
.fcol a.is-here { color: var(--text); font-weight: 700; }
.fcol p { font-size: 12px; line-height: 1.6; color: var(--muted); }
.fwide { grid-column: span 2; }
.fbottom {
	display: flex; flex-wrap: wrap; gap: 8px 18px; justify-content: space-between;
	max-width: 1180px; margin: 0 auto; padding-top: 14px;
	border-top: 1px solid var(--border); font-size: 11.5px; color: var(--muted);
}

@media (max-width: 900px) {
	.brand-text small { display: none; }
	.fwide { grid-column: span 1; }
}
@media (max-width: 640px) {
	/* the strip stays reachable — it scrolls rather than vanishing */
	.toolnav .tn { padding: 6px 9px; font-size: 12px; }
	.forumlink { display: none; }
	.foot { padding: 20px 14px 14px; }
}


.layout > * { min-width: 0; }

/* ============================================================
   Touch screens
   The wordmark is 187px wide — together with the tool strip and the two
   toggles it overflowed a 375px phone. Narrow screens show the icon
   instead, which frees the width the navigation actually needs.
   ============================================================ */
.brand-icon { display: none; }

@media (max-width: 700px) {
	.topbar { padding: 0 10px; gap: 8px; }
	.topbar .brand img { display: none; }
	.topbar .brand .brand-icon { display: block; height: 30px; width: 30px; }
	/* the tool strip already names the current page, so the heading is spare */
	.brand-text { display: none; }
	.toplinks { flex: 1; min-width: 0; justify-content: flex-end; }
}

/* Fingers need a bigger target than a mouse pointer. Applied only where the
   pointer is coarse so desktop keeps its compact controls. */
@media (pointer: coarse) {
	.toolnav .tn { min-height: 40px; display: flex; align-items: center; }
	#langToggle, #themeToggle { height: 40px; min-width: 40px; }
	.seg button, .qbtns button { min-height: 40px; }
	.actions button, .clearbtn, .morebtn { min-height: 44px; }
	/* the per-format copy buttons are the main thing tapped on this page */
	.drow button, #shareCopy { min-height: 40px; padding: 0 14px; }
	.fcol a { padding: 3px 0; }
	/* the level slider is a thin track; give the thumb room to be grabbed */
	input[type="range"] { height: 40px; }
	select, input[type="text"], input[type="search"],
	input[type="datetime-local"] { min-height: 42px; }
}
