/*
	Sekai Kabuka Clone - Smartphone-first UI
	HTML + CSS + JS + PHP
*/

:root {
	--bg: #0b1220;
	--panel: #0f172a;
	--panel2: #111c33;
	--text: #e5e7eb;
	--muted: #9ca3af;
	--border: rgba(255,255,255,.10);
	--shadow: 0 10px 30px rgba(0,0,0,.35);
	--up: #16a34a;
	--down: #dc2626;
	--accent: #38bdf8;
	--radius: 14px;

	--tile-h: 140px;
	--tile-pad: 12px;
	--tile-gap: 10px;
	--tile-minw: 160px;
}

:root[data-theme="light"] {
	--bg: #f3f4f6;
	--panel: #ffffff;
	--panel2: #f8fafc;
	--text: #0b1220;
	--muted: #6b7280;
	--border: rgba(2,6,23,.12);
	--shadow: 0 10px 30px rgba(2,6,23,.12);
	--accent: #0284c7;
}

* {
	box-sizing: border-box;
}

html, body {
	height: 100%;
}

body {
	margin: 0;
	font-family: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans JP", "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic", sans-serif;
	background: var(--bg);
	color: var(--text);
	-webkit-tap-highlight-color: transparent;
}

a {
	color: inherit;
	text-decoration: none;
}

hr.sep {
	border: 0;
	border-top: 1px solid var(--border);
	margin: 12px 0;
}

/* Topbar */
.topbar {
	position: sticky;
	top: 0;
	z-index: 50;
	display: grid;
	grid-template-columns: 1fr;
	gap: 8px;
	padding: 10px 10px 8px;
	background: linear-gradient(180deg, var(--panel), rgba(0,0,0,0));
	backdrop-filter: blur(8px);
}

.topbar__left,
.topbar__right {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 10px;
}

.brand {
	display: flex;
	align-items: center;
	gap: 8px;
	font-weight: 800;
	letter-spacing: .02em;
	white-space: nowrap;
}

.brand__mark {
	font-size: 18px;
}

.brand__text {
	font-size: 14px;
}

.tabs {
	display: flex;
	gap: 6px;
	overflow-x: auto;
	padding: 2px 2px 6px;
	scrollbar-width: none;
}

.tabs::-webkit-scrollbar {
	display: none;
}

.tab {
	flex: 0 0 auto;
	padding: 8px 10px;
	border: 1px solid var(--border);
	background: rgba(255,255,255,.02);
	border-radius: 999px;
	font-size: 12px;
	color: var(--muted);
	white-space: nowrap;
}

:root[data-theme="light"] .tab {
	background: rgba(2,6,23,.02);
}

.tab.is-active {
	color: var(--text);
	border-color: rgba(56,189,248,.45);
	box-shadow: 0 0 0 2px rgba(56,189,248,.18) inset;
}

.iconbtn {
	min-width: 36px;
	height: 36px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	border-radius: 12px;
	border: 1px solid var(--border);
	background: rgba(255,255,255,.02);
	color: var(--text);
	cursor: pointer;
	font-size: 16px;
	user-select: none;
}

.iconbtn:active {
	transform: translateY(1px);
}


.iconbtn.is-on {
	border-color: rgba(245,158,11,.45);
	color: #f59e0b;
	box-shadow: 0 0 0 2px rgba(245,158,11,.18) inset;
}
.search {
	position: relative;
	flex: 1 1 auto;
	min-width: 180px;
}

.search__input {
	width: 100%;
	height: 36px;
	padding: 0 34px 0 12px;
	border-radius: 12px;
	border: 1px solid var(--border);
	background: rgba(255,255,255,.02);
	color: var(--text);
	outline: none;
}

.search__input::placeholder {
	color: rgba(156,163,175,.85);
}

.search__clear {
	position: absolute;
	right: 6px;
	top: 50%;
	transform: translateY(-50%);
	width: 26px;
	height: 26px;
	border-radius: 10px;
	border: 1px solid var(--border);
	background: rgba(255,255,255,.03);
	color: var(--muted);
	cursor: pointer;
}

/* Main */
.main {
	padding: 0 10px 24px;
}

.headline {
	display: grid;
	gap: 4px;
	margin: 8px 0 10px;
}

.headline__title {
	margin: 0;
	font-size: 16px;
	font-weight: 800;
}

.headline__desc {
	margin: 0;
	font-size: 12px;
	color: var(--muted);
}

.headline__meta {
	display: flex;
	gap: 10px;
	align-items: center;
	flex-wrap: wrap;
	margin-top: 4px;
}

.status, .clock {
	font-size: 12px;
	color: var(--muted);
	padding: 4px 8px;
	border-radius: 999px;
	border: 1px solid var(--border);
	background: rgba(255,255,255,.02);
}

.controls {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	margin: 8px 0 12px;
}

.seg {
	display: flex;
	gap: 6px;
	overflow-x: auto;
	scrollbar-width: none;
}

.seg::-webkit-scrollbar {
	display: none;
}

.seg__btn {
	flex: 0 0 auto;
	height: 32px;
	padding: 0 10px;
	border-radius: 999px;
	border: 1px solid var(--border);
	background: rgba(255,255,255,.02);
	color: var(--muted);
	cursor: pointer;
	font-size: 12px;
}

.seg__btn.is-active {
	color: var(--text);
	border-color: rgba(56,189,248,.45);
	box-shadow: 0 0 0 2px rgba(56,189,248,.18) inset;
}

.hint {
	font-size: 11px;
	color: var(--muted);
}

/* Grid */
.grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(var(--tile-minw), 1fr));
	gap: var(--tile-gap);
}

/* Tile */
.tile {
	position: relative;
	display: grid;
	grid-template-rows: auto auto 1fr auto;
	gap: 6px;
	height: var(--tile-h);
	padding: var(--tile-pad);
	border-radius: var(--radius);
	border: 1px solid var(--border);
	background: linear-gradient(180deg, rgba(255,255,255,.03), rgba(255,255,255,.01));
	box-shadow: var(--shadow);
	overflow: hidden;
}

:root[data-theme="light"] .tile {
	background: linear-gradient(180deg, rgba(2,6,23,.03), rgba(2,6,23,.01));
}

.tile::after {
	content: "";
	position: absolute;
	inset: -20px -20px auto auto;
	width: 120px;
	height: 120px;
	border-radius: 999px;
	background: radial-gradient(circle at center, rgba(56,189,248,.20), rgba(0,0,0,0));
	filter: blur(8px);
	pointer-events: none;
}

.tile.is-up {
	border-color: rgba(22,163,74,.35);
}

.tile.is-down {
	border-color: rgba(220,38,38,.35);
}

.tile__top {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 8px;
}

.tile__title {
	font-size: 12px;
	font-weight: 800;
	letter-spacing: .01em;
	line-height: 1.2;
}

.tile__fav {
	width: 28px;
	height: 28px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	border-radius: 10px;
	border: 1px solid var(--border);
	background: rgba(255,255,255,.02);
	color: rgba(156,163,175,.9);
	cursor: pointer;
}

.tile__fav.is-on {
	color: #f59e0b;
	border-color: rgba(245,158,11,.45);
	box-shadow: 0 0 0 2px rgba(245,158,11,.18) inset;
}

.tile__mid {
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	gap: 8px;
}

.tile__price {
	font-size: 18px;
	font-weight: 900;
	letter-spacing: .01em;
}

.tile__chg {
	font-size: 11px;
	font-weight: 700;
	color: var(--muted);
	white-space: nowrap;
}

.tile.is-up .tile__chg {
	color: var(--up);
}

.tile.is-down .tile__chg {
	color: var(--down);
}

.tile__spark {
	width: 100%;
	height: 42px;
	display: block;
}

.tile__foot {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 6px;
	font-size: 10px;
	color: var(--muted);
}

.badge {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 3px 8px;
	border-radius: 999px;
	border: 1px solid var(--border);
	background: rgba(255,255,255,.02);
	font-size: 10px;
	color: var(--muted);
}

/* Footer */
.footer {
	display: flex;
	align-items: flex-start;
	justify-content: space-between;
	gap: 12px;
	padding: 14px 2px 0;
	color: var(--muted);
	font-size: 11px;
}

/* Drawer */
.drawer {
	position: fixed;
	inset: 0;
	z-index: 100;
	display: none;
}

.drawer.is-open {
	display: block;
}

.drawer__backdrop {
	position: absolute;
	inset: 0;
	background: rgba(0,0,0,.55);
}

.drawer__panel {
	position: absolute;
	right: 0;
	top: 0;
	height: 100%;
	width: min(420px, 92vw);
	background: var(--panel);
	border-left: 1px solid var(--border);
	box-shadow: var(--shadow);
	display: grid;
	grid-template-rows: auto 1fr;
}

.drawer__header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 12px 12px 10px;
	border-bottom: 1px solid var(--border);
}

.drawer__title {
	margin: 0;
	font-size: 14px;
	font-weight: 900;
}

.drawer__body {
	padding: 12px;
	overflow: auto;
}

.field {
	display: grid;
	gap: 6px;
	margin: 10px 0;
}

.field__label {
	font-size: 12px;
	color: var(--muted);
}

.field__control {
	height: 36px;
	border-radius: 12px;
	border: 1px solid var(--border);
	background: rgba(255,255,255,.02);
	color: var(--text);
	padding: 0 10px;
	outline: none;
}

.field__help {
	font-size: 11px;
	color: var(--muted);
	line-height: 1.35;
}

.row {
	display: flex;
	gap: 8px;
	align-items: center;
}

.btn {
	height: 36px;
	padding: 0 12px;
	border-radius: 12px;
	border: 1px solid var(--border);
	background: rgba(255,255,255,.02);
	color: var(--text);
	cursor: pointer;
	font-size: 12px;
	font-weight: 800;
}

.btn:active {
	transform: translateY(1px);
}

.btn--danger {
	border-color: rgba(220,38,38,.35);
	color: #fecaca;
}

/* Pages (News / Calendar / About) */
.page {
	padding: 14px 10px 24px;
	display: grid;
	gap: 12px;
}

.card {
	border: 1px solid var(--border);
	border-radius: var(--radius);
	background: rgba(255,255,255,.02);
	box-shadow: var(--shadow);
	padding: 12px;
}

.card__title {
	margin: 0 0 6px;
	font-size: 14px;
	font-weight: 900;
}

.card__desc {
	margin: 0;
	font-size: 12px;
	color: var(--muted);
	line-height: 1.5;
}

.list {
	display: grid;
	gap: 10px;
}

.newsitem {
	display: grid;
	gap: 4px;
	padding: 10px;
	border-radius: 12px;
	border: 1px solid var(--border);
	background: rgba(255,255,255,.02);
}

.newsitem__title {
	font-size: 13px;
	font-weight: 800;
	line-height: 1.35;
}

.newsitem__meta {
	font-size: 11px;
	color: var(--muted);
}

/* Tile size presets */
:root[data-tilesize="s"] {
	--tile-h: 125px;
	--tile-minw: 150px;
	--tile-pad: 10px;
}

:root[data-tilesize="m"] {
	--tile-h: 140px;
	--tile-minw: 160px;
	--tile-pad: 12px;
}

:root[data-tilesize="l"] {
	--tile-h: 160px;
	--tile-minw: 175px;
	--tile-pad: 13px;
}

/* Wider screens */
@media (min-width: 900px) {
	.topbar {
		grid-template-columns: auto 1fr auto;
		align-items: center;
	}
	.topbar__left {
		justify-content: flex-start;
	}
	.topbar__right {
		justify-content: flex-end;
	}
	.brand__text {
		font-size: 15px;
	}
	.search {
		min-width: 280px;
	}
	.main {
		padding: 0 16px 28px;
	}
	.headline__title {
		font-size: 18px;
	}
}
