/* ==========================================
   Qchan - iOS Dark Mode Theme
   ========================================== */

:root {
	--bg-primary: #000000;
	--bg-secondary: #1c1c1e;
	--bg-tertiary: #2c2c2e;
	--bg-elevated: #3a3a3c;
	--text-primary: #ffffff;
	--text-secondary: #98989d;
	--text-tertiary: #636366;
	--accent: #0a84ff;
	--accent-hover: #409cff;
	--green: #30d158;
	--red: #ff453a;
	--orange: #ff9f0a;
	--separator: rgba(84,84,88,0.65);
	--overlay: rgba(0,0,0,0.6);
	--card-radius: 12px;
	--btn-radius: 10px;
	--header-height: 54px;
	--footer-height: 44px;
	--safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* Reset */
*, *::before, *::after {
	margin: 0;
	padding: 0;
	box-sizing: border-box;
}
html {
	font-size: 16px;
	-webkit-text-size-adjust: 100%;
}
body {
	font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", Arial, sans-serif;
	background-color: var(--bg-primary);
	color: var(--text-primary);
	line-height: 1.47;
	-webkit-font-smoothing: antialiased;
	overflow-x: hidden;
}
a {
	color: var(--accent);
	text-decoration: none;
}
a:hover {
	color: var(--accent-hover);
}
img {
	border: none;
	max-width: 100%;
}
ul, ol {
	list-style: none;
}
button {
	font-family: inherit;
	cursor: pointer;
	border: none;
	outline: none;
	-webkit-tap-highlight-color: transparent;
}
input, textarea {
	font-family: inherit;
	outline: none;
	-webkit-tap-highlight-color: transparent;
}

/* ==========================================
   Header
   ========================================== */
#main_header {
	position: fixed;
	top: 0;
	left: 0;
	right: 0;
	z-index: 10000;
	height: var(--header-height);
	background: rgba(28,28,30,0.85);
	-webkit-backdrop-filter: saturate(180%) blur(20px);
	backdrop-filter: saturate(180%) blur(20px);
	border-bottom: 0.5px solid var(--separator);
}
#header_inner {
	max-width: 1200px;
	margin: 0 auto;
	height: 100%;
	display: flex;
	align-items: center;
	padding: 0 16px;
}
#logo_wrap {
	flex-shrink: 0;
	margin-right: 24px;
}
#logo_text {
	font-size: 18px;
	font-weight: 700;
	letter-spacing: -0.3px;
	color: var(--text-primary);
}
#header_nav {
	display: flex;
	gap: 4px;
	background: var(--bg-tertiary);
	border-radius: 8px;
	padding: 2px;
}
.nav_tab {
	display: inline-block;
	padding: 5px 18px;
	font-size: 13px;
	font-weight: 500;
	color: var(--text-secondary);
	border-radius: 6px;
	cursor: pointer;
	transition: all 0.2s ease;
	user-select: none;
}
.nav_tab.active {
	background: var(--bg-elevated);
	color: var(--text-primary);
}
.nav_tab:hover:not(.active) {
	color: var(--text-primary);
}
#header_actions {
	margin-left: auto;
	display: flex;
	align-items: center;
}
#lang_sel {
	position: relative;
	padding: 8px;
	cursor: pointer;
	color: var(--text-secondary);
	border-radius: 8px;
	transition: background 0.15s;
}
#lang_sel:hover {
	background: var(--bg-tertiary);
	color: var(--text-primary);
}
.icon_svg {
	display: block;
}
#lang_list {
	display: none;
	position: absolute;
	top: calc(100% + 8px);
	right: 0;
	background: var(--bg-secondary);
	border: 0.5px solid var(--separator);
	border-radius: var(--card-radius);
	padding: 6px 0;
	min-width: 180px;
	max-height: 320px;
	overflow-y: auto;
	z-index: 10001;
	box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}
#lang_sel:hover #lang_list {
	display: block;
}
#lang_list li {
	padding: 0;
}
#lang_list li a {
	display: block;
	padding: 8px 16px;
	font-size: 14px;
	color: var(--text-primary);
	transition: background 0.15s;
}
#lang_list li a:hover {
	background: var(--bg-tertiary);
}

/* ==========================================
   Main Content Area
   ========================================== */
#main {
	position: relative;
	min-height: calc(100vh - var(--header-height) - var(--footer-height));
	margin-top: var(--header-height);
	padding: 20px 16px;
	padding-bottom: calc(20px + var(--footer-height));
	max-width: 1200px;
	margin-left: auto;
	margin-right: auto;
}

/* Tab panels */
.tab_panel {
	display: none;
}
.tab_panel.active {
	display: block;
}

/* ==========================================
   Upload Panel
   ========================================== */
#first_load {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	min-height: 50vh;
	color: var(--text-tertiary);
}
#add {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 100px;
	height: 100px;
	border: 2px dashed var(--bg-elevated);
	border-radius: 20px;
	font-size: 40px;
	color: var(--text-tertiary);
	cursor: pointer;
	transition: all 0.2s ease;
	text-decoration: none;
	margin-bottom: 16px;
}
#add:hover {
	border-color: var(--accent);
	color: var(--accent);
	background: rgba(10,132,255,0.08);
}
#first_load p {
	font-size: 15px;
	margin: 4px 0;
	color: var(--text-secondary);
}
.compatible {
	font-size: 12px;
	color: var(--text-tertiary);
}

/* Upload popup overlay */
#upload_popup {
	position: fixed;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	background: var(--overlay);
	display: none;
	z-index: 20000;
	align-items: center;
	justify-content: center;
}
#upload_popup.show {
	display: flex;
}
#pop_window {
	width: 480px;
	max-width: calc(100vw - 32px);
	background: var(--bg-secondary);
	border-radius: 14px;
	overflow: hidden;
	box-shadow: 0 16px 48px rgba(0,0,0,0.6);
}
#pop_window header {
	padding: 16px 20px;
	font-size: 17px;
	font-weight: 600;
	color: var(--text-primary);
	border-bottom: 0.5px solid var(--separator);
}

/* Method tabs */
#method_change {
	display: flex;
	gap: 4px;
	padding: 12px 20px 0;
	background: transparent;
}
#method_change a {
	flex: 1;
	text-align: center;
	padding: 8px 0;
	font-size: 14px;
	font-weight: 500;
	color: var(--text-secondary);
	background: var(--bg-tertiary);
	border-radius: 8px;
	cursor: pointer;
	transition: all 0.2s;
}
#method_change a:not(.noact) {
	background: var(--accent);
	color: #fff;
}
#method_change a.noact:hover {
	background: var(--bg-elevated);
	color: var(--text-primary);
}

/* Upload zones */
.zone {
	padding: 16px 20px;
}
#url_zone {
	display: none;
}
#file_list {
	visibility: hidden;
	width: 0;
	height: 0;
	position: absolute;
}
#file_select {
	display: block;
	width: 100%;
	padding: 12px;
	font-size: 15px;
	font-weight: 500;
	color: #fff;
	background: var(--accent);
	border-radius: var(--btn-radius);
	transition: background 0.15s;
}
#file_select:hover {
	background: var(--accent-hover);
}
#file_review {
	margin-top: 12px;
	max-height: 160px;
	overflow-y: auto;
	border-radius: 8px;
}
#file_review p {
	padding: 8px 12px;
	font-size: 13px;
	color: var(--text-secondary);
	border-bottom: 0.5px solid var(--separator);
	background: var(--bg-tertiary);
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}
#file_review p:last-child {
	border-bottom: none;
}
#url_list {
	width: 100%;
	min-height: 120px;
	padding: 12px;
	font-size: 14px;
	line-height: 1.5;
	color: var(--text-primary);
	background: var(--bg-tertiary);
	border: 1px solid transparent;
	border-radius: 8px;
	resize: vertical;
	transition: border-color 0.2s;
}
#url_list::placeholder {
	color: var(--text-tertiary);
}
#url_list:focus {
	border-color: var(--accent);
}

/* Submit zone */
#submit_zone {
	display: flex;
	gap: 10px;
	padding: 12px 20px 16px;
	justify-content: flex-end;
}
#closepop {
	padding: 10px 20px;
	font-size: 15px;
	font-weight: 500;
	color: var(--text-primary);
	background: var(--bg-tertiary);
	border-radius: var(--btn-radius);
	transition: background 0.15s;
}
#closepop:hover {
	background: var(--bg-elevated);
}
#submit {
	padding: 10px 24px;
	font-size: 15px;
	font-weight: 500;
	color: #fff;
	background: var(--accent);
	border-radius: var(--btn-radius);
	transition: background 0.15s;
}
#submit:hover {
	background: var(--accent-hover);
}

/* Upload button in header area */
#upload_button_wrap {
	display: none;
}

/* ==========================================
   Result Zone (uploaded images)
   ========================================== */
#result_zone {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
	gap: 8px;
	margin-top: 16px;
}
#result_zone li {
	position: relative;
	aspect-ratio: 1;
	border-radius: var(--card-radius);
	overflow: hidden;
	background: var(--bg-secondary);
	cursor: pointer;
	transition: transform 0.15s ease;
}
#result_zone li:hover {
	transform: scale(1.02);
}
#result_zone li.moving {
	opacity: 0.4;
}
#result_zone div.img {
	position: absolute;
	inset: 0;
	background-size: cover;
	background-position: center;
	background-repeat: no-repeat;
}
#result_zone div.progress {
	position: absolute;
	inset: 0;
	right: 0;
	background: rgba(0,0,0,0.5);
	transition: left 0.3s linear;
}
#result_zone div.name {
	position: absolute;
	inset: 0;
	display: none;
}
#result_zone li:hover div.name {
	display: block;
}
#result_zone div.name p {
	position: absolute;
	bottom: 0;
	left: 0;
	right: 0;
	padding: 8px 10px;
	font-size: 11px;
	color: #fff;
	background: linear-gradient(transparent, rgba(0,0,0,0.7));
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}
#result_zone div.infotag {
	position: absolute;
	top: 6px;
	right: 6px;
	display: none;
	font-size: 10px;
}
#result_zone li.long div.infotag,
#result_zone li.tiny div.infotag {
	display: flex;
	gap: 4px;
}
#result_zone div.infotag span {
	display: none;
	padding: 2px 6px;
	border-radius: 4px;
	font-weight: 500;
}
#result_zone div.infotag span.longtag {
	background: rgba(0,128,128,0.8);
	color: #fff;
}
#result_zone div.infotag span.tinytag {
	background: rgba(165,42,42,0.8);
	color: #fff;
}
#result_zone li.long div.infotag span.longtag {
	display: inline;
}
#result_zone li.tiny div.infotag span.tinytag {
	display: inline;
}
#result_zone div.select {
	position: absolute;
	inset: 0;
	border: 3px solid var(--accent);
	border-radius: var(--card-radius);
	display: none;
}
#result_zone .selected div.select {
	display: block;
}
#result_zone div.select p {
	position: absolute;
	top: 8px;
	left: 8px;
	width: 22px;
	height: 22px;
	background: var(--accent);
	border-radius: 50%;
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 12px;
	color: #fff;
}
#result_zone li.koko {
	background: none;
	border: 2px dashed var(--bg-elevated);
	border-radius: var(--card-radius);
}

/* ==========================================
   Gallery Panel
   ========================================== */
#gallery_panel {
	padding-top: 8px;
}
#gallery_grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
	gap: 8px;
}
.gallery_item {
	position: relative;
	aspect-ratio: 1;
	border-radius: var(--card-radius);
	overflow: hidden;
	background: var(--bg-secondary);
	cursor: pointer;
	transition: transform 0.15s ease;
}
.gallery_item:hover {
	transform: scale(1.02);
}
.gallery_item img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
	transition: opacity 0.3s;
}
.gallery_item img.loading {
	opacity: 0;
}
.gallery_item_overlay {
	position: absolute;
	bottom: 0;
	left: 0;
	right: 0;
	padding: 24px 10px 8px;
	background: linear-gradient(transparent, rgba(0,0,0,0.7));
	opacity: 0;
	transition: opacity 0.2s;
}
.gallery_item:hover .gallery_item_overlay {
	opacity: 1;
}
.gallery_item_name {
	font-size: 11px;
	color: #fff;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}
.gallery_item_date {
	font-size: 10px;
	color: rgba(255,255,255,0.6);
	margin-top: 2px;
}

/* Gallery pagination */
#gallery_pagination {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	margin-top: 24px;
	padding-bottom: 16px;
}
.page_btn {
	padding: 8px 16px;
	font-size: 14px;
	font-weight: 500;
	color: var(--accent);
	background: var(--bg-secondary);
	border: 0.5px solid var(--separator);
	border-radius: var(--btn-radius);
	transition: all 0.15s;
}
.page_btn:hover:not(:disabled) {
	background: var(--bg-tertiary);
}
.page_btn:disabled {
	color: var(--text-tertiary);
	cursor: default;
}
#gallery_page_info {
	font-size: 13px;
	color: var(--text-secondary);
	padding: 0 8px;
}
#gallery_empty {
	text-align: center;
	padding: 80px 20px;
	color: var(--text-tertiary);
	font-size: 15px;
}
#gallery_loading {
	text-align: center;
	padding: 60px 20px;
	color: var(--text-tertiary);
	font-size: 14px;
}

/* ==========================================
   Lightbox
   ========================================== */
#lightbox {
	display: none;
	position: fixed;
	inset: 0;
	z-index: 30000;
	background: rgba(0,0,0,0.92);
	-webkit-backdrop-filter: blur(10px);
	backdrop-filter: blur(10px);
	align-items: center;
	justify-content: center;
	flex-direction: column;
}
#lightbox.show {
	display: flex;
}
#lightbox_close {
	position: absolute;
	top: 12px;
	right: 16px;
	width: 36px;
	height: 36px;
	display: flex;
	align-items: center;
	justify-content: center;
	background: rgba(255,255,255,0.1);
	border-radius: 50%;
	color: #fff;
	font-size: 18px;
	cursor: pointer;
	transition: background 0.15s;
	z-index: 30001;
}
#lightbox_close:hover {
	background: rgba(255,255,255,0.2);
}
#lightbox_img {
	max-width: 90vw;
	max-height: 80vh;
	border-radius: 8px;
	object-fit: contain;
}
#lightbox_info {
	margin-top: 16px;
	text-align: center;
	max-width: 90vw;
}
#lightbox_name {
	font-size: 14px;
	color: var(--text-secondary);
	margin-bottom: 8px;
}
#lightbox_links {
	display: flex;
	gap: 8px;
	justify-content: center;
	flex-wrap: wrap;
}
.lightbox_link_btn {
	padding: 6px 14px;
	font-size: 13px;
	font-weight: 500;
	color: var(--accent);
	background: rgba(10,132,255,0.12);
	border-radius: 6px;
	cursor: pointer;
	transition: background 0.15s;
	border: none;
}
.lightbox_link_btn:hover {
	background: rgba(10,132,255,0.22);
}

/* Copy toast */
#copy_toast {
	display: none;
	position: fixed;
	top: 50%;
	left: 50%;
	transform: translate(-50%, -50%);
	padding: 10px 24px;
	background: var(--bg-elevated);
	color: var(--text-primary);
	border-radius: 10px;
	font-size: 14px;
	z-index: 40000;
	box-shadow: 0 4px 16px rgba(0,0,0,0.4);
}

/* ==========================================
   Info Zone (upload results)
   ========================================== */
#info_zone {
	position: fixed;
	left: 0;
	right: 0;
	bottom: 0;
	z-index: 15000;
	background: rgba(28,28,30,0.92);
	-webkit-backdrop-filter: saturate(180%) blur(20px);
	backdrop-filter: saturate(180%) blur(20px);
	border-top: 0.5px solid var(--separator);
	padding: 12px 16px;
	max-height: 220px;
	overflow-y: auto;
	transition: all 0.25s ease;
}
#info_zone.hide {
	padding: 0 16px;
	max-height: 0;
	overflow: hidden;
	border-top: none;
}
#info_zone h1 {
	font-size: 15px;
	font-weight: 600;
	margin-bottom: 4px;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}
#info_zone p {
	margin: 3px 0;
	font-size: 13px;
	color: var(--text-secondary);
}
#info_zone p.result_info input,
#info_zone p.result_info textarea {
	width: 100%;
	max-width: 500px;
	padding: 6px 10px;
	font-size: 13px;
	font-family: "SF Mono", Menlo, monospace;
	color: var(--text-primary);
	background: var(--bg-tertiary);
	border: 1px solid var(--separator);
	border-radius: 6px;
	margin-top: 2px;
}
#info_zone p.result_info input:focus,
#info_zone p.result_info textarea:focus {
	border-color: var(--accent);
}
#info_zone p.result_info label {
	font-size: 12px;
	color: var(--text-secondary);
	margin-left: 8px;
}
#info_zone p.result_info textarea {
	height: 80px;
	resize: none;
}
#info_zone p.result_info label.multi {
	display: inline-block;
	padding: 4px 10px;
	margin: 2px;
	background: var(--bg-tertiary);
	border-radius: 6px;
	cursor: pointer;
	transition: background 0.15s;
}
#info_zone p.result_info label.multi:hover {
	background: var(--bg-elevated);
}
#info_zone p.result_info label.multi.actived {
	background: var(--accent);
	color: #fff;
}

/* ==========================================
   Footer
   ========================================== */
#main_footer {
	position: fixed;
	bottom: 0;
	left: 0;
	right: 0;
	z-index: 9998;
	height: var(--footer-height);
	background: rgba(28,28,30,0.85);
	-webkit-backdrop-filter: saturate(180%) blur(20px);
	backdrop-filter: saturate(180%) blur(20px);
	border-top: 0.5px solid var(--separator);
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 0 16px;
	padding-bottom: var(--safe-bottom);
}
#main_footer p {
	font-size: 12px;
	color: var(--text-tertiary);
	text-align: center;
}
#main_footer a {
	color: var(--text-secondary);
}
#main_footer a:hover {
	color: var(--accent);
}
#main_site {
	position: absolute;
	left: 16px;
	top: 50%;
	transform: translateY(-50%);
}
#main_site img {
	height: 24px;
	vertical-align: middle;
}

/* Drag over state */
body.dragover::after {
	content: '';
	position: fixed;
	inset: 0;
	border: 3px dashed var(--accent);
	border-radius: 12px;
	margin: 8px;
	background: rgba(10,132,255,0.06);
	z-index: 50000;
	pointer-events: none;
}

/* Scrollbar */
::-webkit-scrollbar {
	width: 6px;
	height: 6px;
}
::-webkit-scrollbar-track {
	background: transparent;
}
::-webkit-scrollbar-thumb {
	background: var(--bg-elevated);
	border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
	background: var(--text-tertiary);
}

/* ==========================================
   Page content (agreement, privacy)
   ========================================== */
#main h1 {
	font-size: 22px;
	font-weight: 700;
	margin-bottom: 16px;
	letter-spacing: -0.3px;
}
#main h2 {
	font-size: 17px;
	font-weight: 600;
	margin: 20px 0 8px;
	color: var(--text-primary);
}
#main > p {
	font-size: 15px;
	color: var(--text-secondary);
	line-height: 1.6;
	margin-bottom: 8px;
}
#main em {
	font-style: italic;
	color: var(--accent);
}

/* ==========================================
   Mobile Responsive
   ========================================== */
@media screen and (max-width: 768px) {
	:root {
		--header-height: 48px;
		--footer-height: 38px;
	}
	.hide_mobile {
		display: none;
	}
	#header_inner {
		padding: 0 12px;
	}
	#logo_text {
		font-size: 16px;
	}
	#logo_wrap {
		margin-right: 12px;
	}
	.nav_tab {
		padding: 4px 14px;
		font-size: 12px;
	}
	#main {
		padding: 12px;
		padding-bottom: calc(12px + var(--footer-height));
	}
	#result_zone,
	#gallery_grid {
		grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
		gap: 4px;
	}
	#pop_window {
		width: 100%;
		max-width: 100vw;
		border-radius: 14px 14px 0 0;
		position: fixed;
		bottom: 0;
		left: 0;
		right: 0;
	}
	#upload_popup {
		align-items: flex-end;
	}
	#pop_window header {
		padding: 14px 16px;
		font-size: 15px;
	}
	.zone {
		padding: 12px 16px;
	}
	#submit_zone {
		padding: 10px 16px 16px;
	}
	#submit.show {
		display: inline-block;
	}
	#add {
		width: 80px;
		height: 80px;
		font-size: 32px;
	}
	#first_load p {
		font-size: 14px;
	}
	#info_zone {
		max-height: 180px;
		padding: 10px 12px;
	}
	#info_zone h1 {
		font-size: 14px;
	}
	#info_zone p.result_info input,
	#info_zone p.result_info textarea {
		max-width: 100%;
	}
	#lightbox_img {
		max-width: 95vw;
		max-height: 70vh;
	}
}

@media screen and (max-width: 480px) {
	#result_zone,
	#gallery_grid {
		grid-template-columns: repeat(3, 1fr);
		gap: 3px;
	}
	.gallery_item {
		border-radius: 6px;
	}
	#result_zone li {
		border-radius: 6px;
	}
}
