/* stylelint-disable palace-hig/prefer-sdk-primitives */

/* Celadon tokens - shared palette with the native shells (subset). */
:root {
  --bg: #eef2ec;
  --surface: #f7faf5;
  --surface-2: #e6ece2;
  --text: #2b332b;
  --text-muted: #6d7a6c;
  --accent: #4f7a5b;
  --accent-muted: #8aa890;
  --gold: #b8945a;
  --line: #d6ddd2;
  --radius: 18px;
  --palace-space-1: 4px;
  --palace-space-2: 8px;
  --palace-space-3: 12px;
  --palace-space-4: 16px;
  --palace-space-5: 20px;
  --palace-space-6: 24px;
  --palace-space-24: 96px;
  --palace-size-target: 48px;
  --text-xs: 12px;
  --text-sm: 13px;
  --text-base: 15px;
  --text-md: 16px;
  --text-lg: 18px;
  --text-xl: 20px;
  --text-2xl: 26px;
  --text-3xl: 30px;
  --text-hero: 40px;

  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: #d3dace;
  display: flex;
  justify-content: center;
  min-height: 100vh;
}

.phone {
  width: 393px;
  min-height: 100vh;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  position: relative;
  box-shadow: 0 0 0 1px var(--line);
}

.app {
  flex: 1;
  overflow-y: auto;
  padding: var(--palace-space-6) var(--palace-space-5) var(--palace-space-24);
}

.screen-loading,
.screen-error {
  padding: 40px var(--palace-space-2);
  color: var(--text-muted);
}

.screen-error {
  color: #9a4a3a;
}

/* greeting */
.home-greeting {
  margin-bottom: var(--palace-space-6);
}

.greeting-line {
  color: var(--text-muted);
  font-size: var(--text-base);
}

.palace-name {
  margin: 2px 0 8px;
  font-size: var(--text-3xl);
  font-weight: 600;
  color: var(--text);
}

.greeting-sub {
  color: var(--accent-muted);
  font-size: var(--text-xs);
  letter-spacing: 0.4px;
}

/* tile grid */
.tile-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--palace-space-4);
}

.tile {
  border: none;
  background: transparent;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--palace-space-2);
}

.tile-glyph {
  width: 60px;
  height: 60px;
  border-radius: 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-lg);
  font-weight: 600;
  color: var(--accent);
}

.tile-label {
  font-size: var(--text-xs);
  color: var(--text);
  text-align: center;
}

/* app store */
.store-head h1,
.app-head h1 {
  font-size: var(--text-2xl);
  color: var(--text);
  margin: 0 0 var(--palace-space-1);
}

.store-list {
  margin-top: var(--palace-space-5);
  display: flex;
  flex-direction: column;
  gap: var(--palace-space-3);
}

.store-row {
  display: flex;
  align-items: center;
  gap: var(--palace-space-3);
  padding-block: var(--palace-space-3);
  border-bottom: 1px solid var(--line);
}

.store-glyph {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  flex: 0 0 44px;
  background: var(--surface-2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  color: var(--accent);
  font-size: var(--text-sm);
}

.store-meta {
  flex: 1;
  min-width: 0;
}

.store-name {
  font-size: var(--text-base);
  color: var(--text);
  font-weight: 600;
}

.store-ver {
  font-size: var(--text-xs);
  color: var(--text-muted);
  font-weight: 400;
}

.store-desc {
  font-size: var(--text-xs);
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.store-state {
  font-size: var(--text-xs);
  color: var(--accent);
  font-weight: 600;
  flex: 0 0 auto;
}

.store-state.is-installed {
  color: var(--text-muted);
  border-color: var(--line);
}

/* app screen */
.app-body {
  margin-top: var(--palace-space-5);
}

.app-desc {
  color: var(--text);
  line-height: 1.5;
}

.app-dev {
  margin-top: var(--palace-space-3);
  color: var(--text-muted);
  font-size: var(--text-sm);
}

/* tabs */
.tabs {
  position: sticky;
  bottom: 0;
  display: flex;
  padding-bottom: env(safe-area-inset-bottom);
  background: rgb(247 250 245 / 92%);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
}

.tab {
  flex: 1;
  border: none;
  background: transparent;
  cursor: pointer;
  padding: var(--palace-space-3) 0 var(--palace-space-4);
  font-size: var(--text-xs);
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  align-items: center;
}

.tab span {
  font-size: var(--text-xl);
}

.tab.is-active {
  color: var(--accent);
}

/* signin */
.signin {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 70vh;
}

.signin-card {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: var(--palace-space-4);
  align-items: stretch;
  text-align: center;
}

.signin-card h1 {
  margin: 0;
  color: var(--text);
}

.signin-card label {
  display: flex;
  flex-direction: column;
  gap: var(--palace-space-1);
  text-align: left;
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.signin-card input {
  min-height: var(--palace-size-target);
  font-size: var(--text-md);
  color: var(--text);
}

.signin-card button {
  margin-top: var(--palace-space-2);
  background: var(--accent);
  color: #fff;
  font-size: var(--text-md);
  cursor: pointer;
}

.signin-err {
  color: #9a4a3a;
  font-size: var(--text-sm);
  min-height: 20px;
}
