/*
 * FHC 視窗教室 － 基本樣式（版面配置）
 * 各佈景主題的外觀在 themes.css，以 CSS 變數覆寫。
 */
:root {
  --font: "Microsoft JhengHei", "PingFang TC", "Noto Sans TC", "Heiti TC", system-ui, sans-serif;
  --fs: 13px;
  --text: #111;
  --muted: #666;
  --face: #ece9d8;
  --win-bg: #fff;
  --win-border: #0831d9;
  --title-h: 28px;
  --title-bg: #0a58e0;
  --title-bg-off: #7a96df;
  --title-fg: #fff;
  --radius: 0px;
  --tb-h: 40px;
  --tb-bg: #245edb;
  --tb-fg: #fff;
  --btn-bg: #f4f3ee;
  --btn-border: #003c74;
  --input-bg: #fff;
  --sel-bg: #316ac5;
  --sel-fg: #fff;
  --menu-bg: #fff;
  --menu-fg: #111;
  --menu-hover: #316ac5;
  --menu-hover-fg: #fff;
  --accent: #1e6fd9;
  --shadow: 0 8px 28px rgba(0, 0, 0, .35);
}

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; margin: 0; overflow: hidden; }
body {
  font-family: var(--font);
  font-size: var(--fs);
  color: var(--text);
  background: #000;
  -webkit-text-size-adjust: 100%;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}
button, input, select, textarea { font: inherit; color: inherit; }
input, textarea, .cmd, .np-text, .doc, .br-addr, .dlg-msg { user-select: text; -webkit-user-select: text; }
[hidden] { display: none !important; }
.hidden-input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.noscript { color: #fff; padding: 2em; font-size: 18px; }
a { color: #0645ad; }

.ico { display: inline-flex; flex: none; line-height: 0; vertical-align: middle; }
.ico svg { display: block; }
.ico-blank { width: 16px; height: 16px; }

/* ---------- 桌面 ---------- */
#app-root { position: fixed; inset: 0; }
#desktop { position: absolute; inset: 0 0 var(--tb-h) 0; overflow: hidden; }
#icons { position: absolute; inset: 0; }
#windows { position: absolute; inset: 0; pointer-events: none; }
#windows > * { pointer-events: auto; }

.dicon {
  position: absolute;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 4px 2px; border: 1px solid transparent; border-radius: 3px;
  color: #fff; text-align: center; cursor: default; outline: none;
  touch-action: none;
}
.dicon-label {
  font-size: 12px; line-height: 1.3;
  text-shadow: 0 1px 2px #000, 0 0 3px #000;
  word-break: break-all;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.dicon:hover { background: rgba(255, 255, 255, .12); border-color: rgba(255, 255, 255, .25); }
.dicon.sel, .dicon:focus-visible { background: rgba(49, 106, 197, .55); border-color: rgba(160, 200, 255, .8); }
.dicon.sel .dicon-label { -webkit-line-clamp: 6; }
.dicon.drag { opacity: .75; z-index: 5; }

/* ---------- 桌布（全部以 CSS 繪製） ---------- */
.wp-teal { background: #008080; }
.wp-hills {
  background:
    radial-gradient(ellipse 90% 45% at 30% 105%, #4caf3c 0 60%, transparent 61%),
    radial-gradient(ellipse 80% 40% at 85% 108%, #3c9a2e 0 60%, transparent 61%),
    radial-gradient(ellipse 30% 9% at 22% 24%, rgba(255,255,255,.9), transparent 70%),
    radial-gradient(ellipse 22% 7% at 70% 16%, rgba(255,255,255,.8), transparent 70%),
    linear-gradient(#2f7fe0, #7ab8f5 55%, #cfe7ff);
}
.wp-aurora {
  background:
    radial-gradient(ellipse 60% 40% at 30% 30%, rgba(0, 255, 170, .45), transparent 70%),
    radial-gradient(ellipse 50% 35% at 70% 40%, rgba(120, 80, 255, .5), transparent 70%),
    linear-gradient(160deg, #04122b, #0b2c4d 50%, #03101f);
}
.wp-bloom {
  background:
    radial-gradient(ellipse 35% 55% at 50% 60%, rgba(120, 190, 255, .9), transparent 70%),
    conic-gradient(from 200deg at 50% 62%, #0a3d91, #2f7bff, #9bd0ff, #2f7bff, #0a3d91, #2f7bff, #9bd0ff, #0a3d91),
    #0a3d91;
  background-blend-mode: screen, normal;
}
.wp-sunset { background: linear-gradient(#2b1055 0%, #7c2a8c 35%, #e65c4f 65%, #fdb55c 85%, #ffd98e 100%); }
.wp-night {
  background:
    radial-gradient(1px 1px at 10% 20%, #fff, transparent), radial-gradient(1px 1px at 30% 70%, #fff, transparent),
    radial-gradient(1.5px 1.5px at 50% 30%, #fff, transparent), radial-gradient(1px 1px at 70% 60%, #fff, transparent),
    radial-gradient(1.5px 1.5px at 85% 15%, #fff, transparent), radial-gradient(1px 1px at 92% 80%, #fff, transparent),
    radial-gradient(1px 1px at 20% 90%, #fff, transparent), radial-gradient(1px 1px at 60% 85%, #fff, transparent),
    radial-gradient(circle at 80% 25%, #f8f3d4 0 3%, rgba(248,243,212,.2) 3.4%, transparent 9%),
    linear-gradient(#020617, #0f1b3d 70%, #1b2b5a);
}
.wp-grid {
  background-color: #f6f8fb;
  background-image: linear-gradient(rgba(30,111,217,.15) 1px, transparent 1px), linear-gradient(90deg, rgba(30,111,217,.15) 1px, transparent 1px);
  background-size: 24px 24px;
}
.wp-grid .dicon, .wp-grid .dicon-label { color: #123; text-shadow: none; }

/* ---------- 視窗 ---------- */
.win {
  position: absolute;
  display: flex; flex-direction: column;
  min-width: 200px; min-height: 100px;
  background: var(--face);
  border: 1px solid var(--win-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  color: var(--text);
}
.win.win-hidden { display: none; }
.win.is-max { left: 0 !important; top: 0 !important; width: 100% !important; height: 100% !important; border-radius: 0; }
.win.is-max .win-rz { display: none; }
.win-title {
  flex: none; display: flex; align-items: center; gap: 6px;
  height: var(--title-h); padding: 0 4px 0 6px;
  background: var(--title-bg-off); color: var(--title-fg);
  touch-action: none; cursor: default;
}
.win-active > .win-title { background: var(--title-bg); }
.win-icon { cursor: pointer; }
.win-title-text { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: bold; }
.win-btns { display: flex; gap: 2px; flex: none; }
.win-btn {
  position: relative; width: 22px; height: 20px; padding: 0;
  border: 1px solid transparent; background: transparent; cursor: pointer;
}
.win-btn span, .win-btn span::before, .win-btn span::after { position: absolute; content: ""; display: block; }
.win-min span { left: 6px; right: 6px; bottom: 5px; height: 2px; background: currentColor; }
.win-max span { left: 5px; top: 4px; right: 5px; bottom: 4px; border: 1px solid currentColor; border-top-width: 2px; }
.is-max .win-max span { left: 7px; top: 3px; right: 3px; bottom: 7px; }
.is-max .win-max span::before { left: -4px; top: 3px; width: 100%; height: 100%; border: 1px solid currentColor; border-top-width: 2px; background: inherit; }
.win-close span::before, .win-close span::after { left: 50%; top: 50%; width: 12px; height: 2px; margin: -1px 0 0 -6px; background: currentColor; }
.win-close span { inset: 0; }
.win-close span::before { transform: rotate(45deg); }
.win-close span::after { transform: rotate(-45deg); }
.win-body { position: relative; flex: 1; min-height: 0; overflow: auto; background: var(--win-bg); }
.win-rz { position: absolute; z-index: 2; touch-action: none; }
.win-rz-n, .win-rz-s { left: 6px; right: 6px; height: 6px; cursor: ns-resize; }
.win-rz-e, .win-rz-w { top: 6px; bottom: 6px; width: 6px; cursor: ew-resize; }
.win-rz-n { top: -3px; } .win-rz-s { bottom: -3px; } .win-rz-e { right: -3px; } .win-rz-w { left: -3px; }
.win-rz-ne, .win-rz-nw, .win-rz-se, .win-rz-sw { width: 12px; height: 12px; }
.win-rz-ne { right: -3px; top: -3px; cursor: nesw-resize; }
.win-rz-sw { left: -3px; bottom: -3px; cursor: nesw-resize; }
.win-rz-nw { left: -3px; top: -3px; cursor: nwse-resize; }
.win-rz-se { right: -3px; bottom: -3px; cursor: nwse-resize; }
body.wm-busy iframe { pointer-events: none; }
body.wm-busy { cursor: grabbing; }

/* ---------- 通用元件 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 4px;
  min-height: 24px; padding: 2px 10px;
  background: var(--btn-bg); border: 1px solid var(--btn-border); border-radius: 3px;
  cursor: pointer; white-space: nowrap;
}
.btn:hover:not(:disabled) { filter: brightness(1.06); }
.btn:active:not(:disabled) { filter: brightness(.92); }
.btn:disabled { opacity: .45; cursor: default; }
.btn-primary { outline: 1px solid var(--accent); outline-offset: -3px; }
.btn-danger { color: #b00020; }
.btn-sm { min-height: 20px; padding: 0 8px; font-size: 12px; }
.btn-icon { min-width: 28px; padding: 2px 6px; }
input[type=text], input[type=search], select, textarea {
  background: var(--input-bg); border: 1px solid #7f9db9; border-radius: 2px; padding: 3px 5px;
}
.muted { color: var(--muted); }
.meter { height: 12px; background: #e3e3e3; border: 1px solid #999; margin: 4px 0; max-width: 260px; }
.meter span { display: block; height: 100%; background: linear-gradient(#5fd068, #2e9e3c); }

.app-col { display: flex; flex-direction: column; overflow: hidden; }
.app-toolbar { flex: none; display: flex; flex-wrap: wrap; align-items: center; gap: 4px; padding: 4px; background: var(--face); border-bottom: 1px solid rgba(0,0,0,.15); }
.app-menubar { flex: none; display: flex; background: var(--face); border-bottom: 1px solid rgba(0,0,0,.12); }
.app-menu { background: none; border: 0; padding: 3px 9px; cursor: pointer; }
.app-menu:hover { background: var(--menu-hover); color: var(--menu-hover-fg); }
.app-status { flex: none; padding: 2px 8px; font-size: 12px; background: var(--face); border-top: 1px solid rgba(0,0,0,.15); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.tabs { flex: none; display: flex; gap: 2px; padding: 6px 6px 0; background: var(--face); border-bottom: 1px solid #999; }
.tab { padding: 4px 12px; border: 1px solid #999; border-bottom: 0; background: rgba(0,0,0,.04); cursor: pointer; border-radius: 4px 4px 0 0; }
.tab.on { background: var(--win-bg); position: relative; top: 1px; }
.tab-pane { flex: 1; min-height: 0; overflow: auto; padding: 8px; display: flex; flex-direction: column; gap: 6px; }

.tbl-wrap { flex: 1; overflow: auto; border: 1px solid #aaa; background: #fff; }
.tbl { width: 100%; border-collapse: collapse; }
.tbl th, .tbl td { padding: 3px 8px; text-align: left; border-bottom: 1px solid #eee; white-space: nowrap; }
.tbl th { background: #f0f0f0; font-weight: normal; position: sticky; top: 0; }
.tbl tr.sel td { background: var(--sel-bg); color: var(--sel-fg); }
.tbl-kv th { width: 80px; }

/* ---------- 對話框 ---------- */
.dlg { display: flex; flex-direction: column; padding: 14px; gap: 12px; background: var(--face); }
.dlg-main { flex: 1; display: flex; gap: 14px; align-items: flex-start; min-height: 0; }
.dlg-text { flex: 1; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.dlg-msg { line-height: 1.6; word-break: break-word; }
.dlg-input { width: 100%; }
.dlg-btns { display: flex; justify-content: flex-end; align-items: center; gap: 8px; flex-wrap: wrap; }
.dlg-btns .muted { margin-right: auto; }
.dlg-btns .btn { min-width: 76px; }
.win-modal .win-title-text { font-weight: bold; }

/* ---------- 右鍵選單 ---------- */
.ctx {
  position: fixed; z-index: 99990; min-width: 190px; padding: 3px;
  background: var(--menu-bg); color: var(--menu-fg);
  border: 1px solid #888; box-shadow: 2px 3px 10px rgba(0,0,0,.35);
  display: flex; flex-direction: column;
}
.ctx-item { display: flex; align-items: center; gap: 8px; padding: 4px 18px 4px 6px; border: 0; background: none; text-align: left; cursor: pointer; white-space: nowrap; }
.ctx-item:hover:not(:disabled), .ctx-item:focus-visible { background: var(--menu-hover); color: var(--menu-hover-fg); outline: none; }
.ctx-item:disabled { opacity: .45; cursor: default; }
.ctx-bold { font-weight: bold; }
.ctx-sep { height: 1px; margin: 3px 2px; background: rgba(0,0,0,.2); }

/* ---------- 工作列 ---------- */
#taskbar {
  position: absolute; left: 0; right: 0; bottom: 0; height: var(--tb-h); z-index: 9000;
  display: flex; align-items: stretch;
  background: var(--tb-bg); color: var(--tb-fg);
}
.tb-center { flex: 1; min-width: 0; display: flex; align-items: center; gap: 4px; }
.tb-start { flex: none; display: flex; align-items: center; gap: 6px; height: 100%; padding: 0 12px 0 8px; border: 0; cursor: pointer; color: inherit; background: transparent; }
.tb-start-text { font-weight: bold; font-size: 15px; }
.tb-quick { flex: none; display: flex; gap: 2px; padding: 0 4px; }
.tb-qbtn { width: 28px; height: 28px; display: grid; place-items: center; border: 1px solid transparent; background: none; border-radius: 3px; cursor: pointer; }
.tb-qbtn:hover { background: rgba(255,255,255,.18); border-color: rgba(255,255,255,.3); }
.tb-tasks { flex: 1; min-width: 0; display: flex; gap: 3px; align-items: center; overflow: hidden; }
.tb-task {
  flex: 0 1 170px; min-width: 40px; height: calc(var(--tb-h) - 10px);
  display: flex; align-items: center; gap: 6px; padding: 0 8px;
  border: 1px solid rgba(255,255,255,.2); border-radius: 3px; background: rgba(255,255,255,.12);
  color: inherit; cursor: pointer; text-align: left;
}
.tb-task-text { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tb-task.active { background: rgba(0,0,0,.25); }
.tb-tray { flex: none; display: flex; align-items: center; gap: 4px; padding: 0 8px; }
.tb-tray-btn { display: grid; place-items: center; width: 24px; height: 24px; border: 0; background: none; color: inherit; cursor: pointer; padding: 0; }
.tb-clock { display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.2; border: 0; background: none; color: inherit; cursor: pointer; padding: 0 4px; font-size: 12px; }
.tb-showdesk { flex: none; width: 8px; border: 0; border-left: 1px solid rgba(255,255,255,.3); background: transparent; cursor: pointer; }
.tb-showdesk:hover { background: rgba(255,255,255,.25); }

/* ---------- 月曆 ---------- */
#calendar {
  position: absolute; right: 6px; bottom: calc(var(--tb-h) + 6px); z-index: 9500;
  width: 270px; padding: 12px; background: var(--menu-bg); color: var(--menu-fg);
  border: 1px solid #888; border-radius: var(--radius); box-shadow: var(--shadow);
}
.cal-time { font-size: 30px; font-weight: 300; }
.cal-date { color: var(--accent); margin-bottom: 8px; }
.cal-head { display: flex; justify-content: space-between; align-items: center; margin: 6px 0; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; text-align: center; }
.cal-grid span { padding: 4px 0; border-radius: 50%; }
.cal-wd { color: var(--muted); font-size: 12px; }
.cal-d.today { background: var(--accent); color: #fff; }

/* ---------- 開始功能表（共同版面） ---------- */
#start-menu {
  position: absolute; left: 0; bottom: var(--tb-h); z-index: 9400;
  display: none; max-height: calc(100% - var(--tb-h) - 4px);
  background: var(--menu-bg); color: var(--menu-fg); box-shadow: var(--shadow);
}
#start-menu.open { display: flex; }
.sm-banner { display: none; }
.sm-main { display: flex; flex-direction: column; min-width: 0; flex: 1; min-height: 0; }
.sm-head { display: flex; align-items: center; gap: 10px; padding: 8px 10px; }
.sm-user { font-size: 16px; font-weight: bold; }
.sm-search { margin: 6px 10px; }
.sm-cols { display: flex; flex: 1; min-height: 0; }
.sm-left { flex: 1; min-width: 0; overflow: auto; padding: 4px; }
.sm-right { flex: none; width: 170px; padding: 6px 4px; overflow: auto; }
.sm-sec-title { padding: 4px 8px; font-size: 12px; font-weight: bold; color: var(--muted); }
.sm-grid { display: flex; flex-direction: column; }
.sm-item, .sm-place {
  display: flex; align-items: center; gap: 8px; padding: 4px 8px;
  border: 0; background: none; color: inherit; text-align: left; cursor: pointer; border-radius: 3px;
}
.sm-item .ico svg { width: 24px; height: 24px; }
.sm-item:hover, .sm-place:hover, .sm-item:focus-visible, .sm-place:focus-visible { background: var(--menu-hover); color: var(--menu-hover-fg); outline: none; }
.sm-place-sep { height: 1px; margin: 4px 6px; background: rgba(0,0,0,.15); }
.sm-empty { padding: 16px; color: var(--muted); }
.sm-foot { display: flex; align-items: center; justify-content: flex-end; gap: 4px; padding: 6px 8px; }
.sm-foot-user { display: none; }
.sm-pw { display: flex; align-items: center; gap: 4px; border: 0; background: none; color: inherit; padding: 4px 8px; cursor: pointer; border-radius: 3px; }
.sm-pw:hover { background: rgba(255,255,255,.2); }

/* ---------- 全螢幕畫面：開機、登入、鎖定、關機、藍屏 ---------- */
.overlay { position: fixed; inset: 0; z-index: 100000; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; color: #fff; }
.boot-post { background: #000; align-items: flex-start; justify-content: flex-start; padding: 24px; font-family: Consolas, "Courier New", monospace; }
.post-text { margin: 0; font: 15px/1.6 Consolas, "Courier New", monospace; color: #c8c8c8; white-space: pre-wrap; }
.boot-logo { background: #000; }
.boot-name { font-size: 30px; letter-spacing: 2px; }
.boot-name b { color: #4a95f0; }
.boot-bar { width: 180px; height: 14px; border: 1px solid #555; border-radius: 3px; overflow: hidden; position: relative; }
.boot-bar span { position: absolute; top: 2px; bottom: 2px; width: 36px; left: -40px; background: linear-gradient(90deg, transparent, #4a95f0, #9fd0ff, #4a95f0, transparent); animation: bootbar 1.4s linear infinite; }
@keyframes bootbar { to { left: 180px; } }
.boot-copy { position: absolute; bottom: 24px; color: #777; font-size: 12px; }
.login { background: linear-gradient(135deg, #1d4ea8, #3a7bd5 55%, #5aa0e8); transition: opacity .4s; }
.login.fade { opacity: 0; }
.login-top { position: absolute; top: 0; left: 0; right: 0; display: flex; align-items: center; gap: 10px; padding: 14px 20px; background: rgba(0,0,30,.35); font-size: 18px; }
.login-mid { display: flex; flex-direction: column; align-items: center; gap: 20px; }
.login-welcome { font-size: 42px; font-style: italic; font-weight: bold; text-shadow: 0 2px 6px rgba(0,0,0,.4); }
.login-user { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 16px 30px; border: 1px solid rgba(255,255,255,.4); border-radius: 10px; background: rgba(255,255,255,.12); cursor: pointer; color: #fff; }
.login-user:hover, .login-user:focus-visible { background: rgba(255,255,255,.25); outline: none; }
.login-avatar { padding: 4px; border-radius: 8px; background: rgba(255,255,255,.3); }
.login-name { font-size: 20px; font-weight: bold; }
.login-hint { font-size: 12px; opacity: .85; }
.login-bottom { position: absolute; bottom: 0; left: 0; right: 0; padding: 12px 20px; background: rgba(0,0,30,.35); font-size: 12px; text-align: center; }
.lock { background: linear-gradient(160deg, #0b2c4d, #1e6fd9); transition: transform .45s ease-in; cursor: pointer; outline: none; }
.lock.up { transform: translateY(-100%); }
.lock-time { font-size: 96px; font-weight: 200; line-height: 1; }
.lock-date { font-size: 24px; }
.lock-hint { position: absolute; bottom: 40px; opacity: .8; }
.shutting { background: rgba(10, 40, 110, .92); font-size: 20px; }
.spin { width: 40px; height: 40px; border: 4px solid rgba(255,255,255,.25); border-top-color: #fff; border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.off { background: #000; color: #f0a030; }
.off-msg { font-size: 22px; text-align: center; padding: 0 20px; }
.off .btn { background: #222; color: #ddd; border-color: #555; }
.bsod { background: #0b4fa8; align-items: flex-start; padding: 8vh 10vw; font-size: 18px; line-height: 1.7; outline: none; cursor: pointer; }
.bsod-face { font-size: 110px; line-height: 1; }
.bsod-code { font-family: Consolas, monospace; font-size: 15px; opacity: .9; }
.bsod-hint { font-size: 14px; opacity: .8; }

/* ---------- 手機與小螢幕 ---------- */
@media (max-width: 699px) {
  :root { --tb-h: 46px; }
  .tb-quick, .tb-date, .tb-net { display: none !important; }
  .tb-task { flex-basis: 44px; }
  .tb-task-text { display: none; }
  #start-menu { left: 0 !important; right: 0; width: auto !important; transform: none !important; }
  .sm-right { display: none; }
  .win { min-width: 0; }
  .lock-time { font-size: 64px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
