/* Generic app shell helpers */
.app-root { display: flex; flex-direction: column; height: 100%; background: var(--bg-window-solid); color: var(--text); }
.app-row { display: flex; height: 100%; }
.sidebar {
  width: 200px; min-width: 160px;
  background: var(--bg-sidebar);
  backdrop-filter: blur(20px);
  border-right: 0.5px solid var(--border);
  padding: 8px 6px; overflow: auto;
}
.sidebar h4 { font-size: 11px; text-transform: uppercase; color: var(--text-faint); padding: 8px 8px 4px; }
.sidebar a, .sidebar button {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 8px; border-radius: 5px; font-size: 13px;
  cursor: default; color: var(--text); width: 100%; text-align: left;
}
.sidebar a:hover, .sidebar button:hover { background: rgba(127,127,127,0.18); }
.sidebar a.active, .sidebar button.active { background: rgba(127,127,127,0.32); }
.app-main { flex: 1; overflow: auto; padding: 12px 16px; }
.toolbar { display: flex; gap: 8px; align-items: center; padding: 8px 12px; border-bottom: 0.5px solid var(--border); background: var(--bg-titlebar); backdrop-filter: blur(20px); }
.toolbar button { padding: 4px 10px; border-radius: 6px; cursor: default; font-size: 13px; }
.toolbar button:hover { background: rgba(127,127,127,0.2); }
.toolbar input[type=text], .toolbar input[type=search] {
  flex: 1; padding: 4px 10px; background: rgba(127,127,127,0.16); border-radius: 6px; font-size: 13px;
}

/* Finder */
.finder-grid {
  display: grid; grid-template-columns: repeat(auto-fill, 100px);
  gap: 12px; padding: 14px;
}
.finder-item {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 6px; border-radius: 6px; cursor: default;
}
.finder-item:hover { background: rgba(127,127,127,0.18); }
.finder-item.selected { background: rgba(0,122,255,0.3); color: #fff; }
.finder-item .ic { width: 56px; height: 56px; display: grid; place-items: center; font-size: 32px; }
.finder-item span { font-size: 12px; text-align: center; max-width: 88px; word-break: break-word; }

/* Calculator */
.calc {
  display: flex; flex-direction: column; height: 100%;
  background: #1c1c1e; color: #fff;
}
.calc-display { flex: 1; padding: 18px 22px; text-align: right; font-size: 56px; font-weight: 200; line-height: 1.05; overflow: hidden; }
.calc-keys { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1px; background: #1c1c1e; }
.calc-key {
  background: #505050; color: #fff; font-size: 22px; padding: 14px 0;
  cursor: default; user-select: none;
}
.calc-key:active { filter: brightness(1.4); }
.calc-key.fn { background: #a5a5a5; color: #000; }
.calc-key.op { background: #ff9f0a; color: #fff; }
.calc-key.zero { grid-column: span 2; }

/* Notes */
.notes { display: flex; height: 100%; }
.notes-list { width: 240px; border-right: 0.5px solid var(--border); background: var(--bg-sidebar); overflow: auto; }
.notes-list .item {
  padding: 10px 14px; border-bottom: 0.5px solid var(--border);
  cursor: default;
}
.notes-list .item.active { background: var(--accent); color: #fff; }
.notes-list .item b { display: block; font-size: 13px; }
.notes-list .item small { font-size: 11px; opacity: 0.7; }
.notes-edit { flex: 1; display: flex; flex-direction: column; }
.notes-edit textarea { flex: 1; padding: 18px 22px; resize: none; font-size: 14px; line-height: 1.45; background: var(--bg-window-solid); color: var(--text); }

/* Terminal */
.term { height: 100%; background: #0c0c0d; color: #d6d6d6; padding: 12px 14px; font-family: var(--font-mono); font-size: 13px; line-height: 1.45; overflow: auto; }
.term .line { white-space: pre-wrap; word-break: break-word; }
.term .prompt { color: #2bff64; }
.term-input { display: flex; gap: 6px; }
.term-input span { color: #2bff64; }
.term-input input { flex: 1; color: #d6d6d6; font-family: inherit; font-size: inherit; background: transparent; border: none; }

/* Calendar */
.cal { display: grid; grid-template-rows: auto 1fr; height: 100%; }
.cal-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 18px; border-bottom: 0.5px solid var(--border); }
.cal-head h2 { font-size: 22px; font-weight: 600; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); grid-auto-rows: 1fr; }
.cal-grid .dow { padding: 6px 8px; font-size: 11px; text-transform: uppercase; color: var(--text-faint); border-bottom: 0.5px solid var(--border); }
.cal-grid .day { padding: 8px; border-right: 0.5px solid var(--border); border-bottom: 0.5px solid var(--border); font-size: 13px; min-height: 70px; }
.cal-grid .day.today b { background: #ff3b30; color: #fff; padding: 2px 6px; border-radius: 50%; }
.cal-grid .day.muted { opacity: 0.35; }
.cal-grid .day .evt { font-size: 11px; background: var(--accent); color: #fff; padding: 1px 5px; border-radius: 4px; margin-top: 4px; }

/* Music */
.music { display: grid; grid-template-rows: 1fr auto; height: 100%; background: linear-gradient(180deg, #2b1d33, #0d0d0d); color: #fff; }
.music-main { display: grid; grid-template-columns: 200px 1fr; height: 100%; }
.music-side { background: rgba(0,0,0,0.4); padding: 14px; overflow: auto; }
.music-side a { display: block; padding: 4px 8px; border-radius: 5px; font-size: 13px; color: #ddd; cursor: default; }
.music-side a:hover { background: rgba(255,255,255,0.1); }
.music-list { padding: 14px; overflow: auto; }
.music-list .track { display: grid; grid-template-columns: 32px 1fr 80px 60px; align-items: center; gap: 10px; padding: 6px 8px; border-radius: 6px; cursor: default; font-size: 13px; }
.music-list .track:hover { background: rgba(255,255,255,0.07); }
.music-list .track.playing { color: #ff5d6c; }
.music-bar { background: rgba(0,0,0,0.5); padding: 10px 18px; display: flex; align-items: center; gap: 12px; }
.music-bar button { font-size: 18px; padding: 4px 10px; cursor: default; }
.music-bar input[type=range] { flex: 1; }

/* Photos */
.photos-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 6px; padding: 10px;
}
.photo-tile { aspect-ratio: 1/1; border-radius: 6px; overflow: hidden; cursor: default; }
.photo-tile svg { width: 100%; height: 100%; }
.photo-viewer { position: absolute; inset: 0; background: #000; display: grid; place-items: center; }

/* Settings */
.settings-list { padding: 8px; overflow: auto; }
.settings-list button { width: 100%; }
.settings-pane { padding: 22px 28px; overflow: auto; }
.settings-pane h2 { font-size: 22px; margin-bottom: 14px; }
.settings-row { display: flex; justify-content: space-between; align-items: center; padding: 10px 0; border-bottom: 0.5px solid var(--border); }
.settings-row:last-child { border-bottom: none; }
.settings-row b { font-weight: 500; }
.switch { position: relative; width: 36px; height: 22px; background: rgba(127,127,127,0.5); border-radius: 12px; cursor: pointer; transition: background 0.2s; }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; background: #fff; border-radius: 50%; transition: left 0.2s; box-shadow: 0 1px 3px rgba(0,0,0,0.3); }
.switch.on { background: #34c759; }
.switch.on::after { left: 16px; }

/* App Store */
.store { display: grid; grid-template-rows: auto 1fr; height: 100%; }
.store-tabs { display: flex; gap: 4px; padding: 8px 14px; border-bottom: 0.5px solid var(--border); background: var(--bg-titlebar); backdrop-filter: blur(20px); }
.store-tabs button { padding: 6px 12px; border-radius: 6px; font-size: 13px; cursor: default; }
.store-tabs button.active { background: var(--accent); color: #fff; }
.store-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px; padding: 16px; overflow: auto;
}
.store-card {
  background: var(--bg-glass); border: 0.5px solid var(--border);
  border-radius: 14px; padding: 14px;
  display: grid; grid-template-columns: 64px 1fr; gap: 12px; align-items: center;
}
.store-card .icon-wrap { width: 64px; height: 64px; }
.store-card .icon-wrap > * { width: 100%; height: 100%; border-radius: 16px; }
.store-card .meta b { display: block; font-size: 14px; }
.store-card .meta small { font-size: 12px; opacity: 0.7; display: block; margin: 2px 0 8px; }
.store-card .install {
  background: rgba(127,127,127,0.3); padding: 4px 14px; border-radius: 14px;
  font-size: 12px; font-weight: 600; cursor: default;
}
.store-card .install.installed { background: rgba(127,127,127,0.18); color: var(--text-soft); }

/* Safari */
.safari { display: flex; flex-direction: column; height: 100%; }
.safari-bar { display: flex; gap: 6px; padding: 8px 12px; border-bottom: 0.5px solid var(--border); align-items: center; background: var(--bg-titlebar); backdrop-filter: blur(20px); }
.safari-bar button { width: 26px; height: 24px; border-radius: 6px; font-size: 14px; cursor: default; }
.safari-bar button:hover { background: rgba(127,127,127,0.2); }
.safari-url { flex: 1; padding: 4px 10px; background: rgba(127,127,127,0.16); border-radius: 8px; font-size: 13px; text-align: center; }
.safari-frame { flex: 1; background: #fff; border: none; }
.safari-tabs { display: flex; gap: 2px; padding: 4px 8px 0; background: var(--bg-titlebar); }
.safari-tab { padding: 6px 12px; font-size: 12px; border-radius: 8px 8px 0 0; cursor: default; background: rgba(127,127,127,0.18); }
.safari-tab.active { background: var(--bg-window-solid); }
.safari-start { padding: 30px; overflow: auto; }
.safari-start h2 { font-size: 28px; margin-bottom: 18px; }
.safari-favs { display: grid; grid-template-columns: repeat(auto-fill, 100px); gap: 18px; }
.safari-fav { display: flex; flex-direction: column; align-items: center; gap: 6px; cursor: default; }
.safari-fav .ic { width: 64px; height: 64px; border-radius: 14px; background: var(--bg-glass); display: grid; place-items: center; font-size: 26px; border: 0.5px solid var(--border); }

/* Generic game canvas */
.game-root { display: flex; flex-direction: column; height: 100%; background: #0d0d10; color: #fff; align-items: center; justify-content: center; gap: 14px; padding: 16px; }
.game-root canvas { background: #000; border-radius: 8px; max-width: 100%; max-height: calc(100% - 80px); image-rendering: pixelated; }
.game-root .stat { font-size: 13px; display: flex; gap: 16px; }
.game-root .ctrl { font-size: 11px; opacity: 0.6; text-align: center; }
.game-root button { padding: 6px 14px; border-radius: 8px; background: var(--accent); color: #fff; cursor: default; }

/* TextEdit */
.textedit { display: flex; flex-direction: column; height: 100%; }
.textedit textarea { flex: 1; padding: 18px 24px; font-size: 14px; line-height: 1.6; resize: none; background: var(--bg-window-solid); color: var(--text); }

/* About */
.about-mac { display: grid; grid-template-columns: 180px 1fr; gap: 22px; padding: 28px; align-items: center; }
.about-mac .logo { width: 160px; height: 160px; display: grid; place-items: center; }
.about-mac h2 { font-size: 24px; font-weight: 500; margin-bottom: 4px; }
.about-mac .ver { color: var(--text-faint); font-size: 13px; margin-bottom: 12px; }
.about-mac .row { display: flex; justify-content: space-between; padding: 4px 0; font-size: 13px; }
.about-mac .row b { color: var(--text-soft); font-weight: 500; }

/* Weather, Clock, Maps tiles */
.weather-app { display: grid; place-items: center; height: 100%; background: linear-gradient(160deg, #5cd0ff, #0d77c2); color: #fff; padding: 24px; text-align: center; }
.weather-app .city { font-size: 26px; font-weight: 300; }
.weather-app .temp { font-size: 86px; font-weight: 200; line-height: 1; }
.weather-app .cond { font-size: 16px; opacity: 0.85; }

.clock-app { display: grid; place-items: center; height: 100%; background: #000; color: #fff; }
.clock-time { font-size: 88px; font-weight: 200; letter-spacing: -0.04em; }
.clock-date { font-size: 18px; opacity: 0.7; }

.maps-app { height: 100%; background: linear-gradient(135deg, #c8e6c9, #a5d6a7); position: relative; overflow: hidden; }
.maps-app .pin { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -100%); font-size: 32px; color: #ff3b30; }
.maps-app .label { position: absolute; bottom: 18px; left: 18px; background: var(--bg-window); padding: 8px 14px; border-radius: 8px; font-size: 13px; }

/* Messages / Mail */
.msgs { display: flex; height: 100%; }
.msgs-list { width: 240px; border-right: 0.5px solid var(--border); overflow: auto; background: var(--bg-sidebar); }
.msgs-list .conv { display: flex; gap: 10px; padding: 10px 12px; cursor: default; border-bottom: 0.5px solid var(--border); }
.msgs-list .conv.active { background: var(--accent); color: #fff; }
.msgs-list .avi { width: 36px; height: 36px; border-radius: 50%; background: var(--accent); display: grid; place-items: center; color: #fff; font-weight: 600; font-size: 13px; }
.msgs-thread { flex: 1; display: flex; flex-direction: column; }
.msgs-msgs { flex: 1; overflow: auto; padding: 14px; display: flex; flex-direction: column; gap: 6px; }
.msgs-msgs .b { padding: 6px 12px; border-radius: 16px; max-width: 75%; font-size: 13px; line-height: 1.35; }
.msgs-msgs .b.them { background: rgba(127,127,127,0.22); align-self: flex-start; }
.msgs-msgs .b.me { background: var(--accent); color: #fff; align-self: flex-end; }
.msgs-input { display: flex; gap: 8px; padding: 8px 12px; border-top: 0.5px solid var(--border); }
.msgs-input input { flex: 1; padding: 6px 12px; background: rgba(127,127,127,0.16); border-radius: 16px; }
.msgs-input button { padding: 4px 12px; border-radius: 14px; background: var(--accent); color: #fff; cursor: default; }
